Certified Platform Developer II Exam QuestionsBrowse all questions from this exam

Certified Platform Developer II Exam - Question 22


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?

Show Answer
Correct Answer: B

The optimal way for a developer to fix the issue is to create a TestDataFactory class that serves as the single place to create Accounts for unit tests and set the required field there. This approach centralizes the account creation logic in one place, making it easier to update and maintain. If new required fields are added in the future, the developer only needs to update the factory class, rather than updating every individual test.

Discussion

3 comments
Sign in to comment
VVeguruOption: B
Jul 20, 2023

B, TestDataFactory is idela way of creating Test data at single place

YNWA_A1Option: B
Jul 20, 2023

B is correct

Jeet89123Option: B
May 29, 2024

best way to create test methods