Salesforce Certified Platform Developer II — Question 198

A company has many different unit test methods that create Account records as part of their data setup. A new required field was added to the Account and now all of the unit tests fail.
What is the optimal way for a developer to fix the issue?

Answer options

Correct answer: B

Explanation

The best solution is to create a TestDataFactory class that standardizes the creation of Account records for unit tests, ensuring that all required fields are consistently populated. This approach minimizes duplication and centralizes changes, making future updates easier. The other options either complicate the process or do not address the root cause of the issue effectively.