Salesforce Certified Platform Developer II — Question 13

A company notices that their unit tests in a test class with many methods to create many records for prerequisite reference data are slow.
What can a developer to do address the issue?

Answer options

Correct answer: B

Explanation

The correct answer is B because @testSetup methods are designed to run once before any test methods in a class, which optimizes the setup process and reduces redundancy. Options A and C introduce additional complexity by requiring a factory or static method, and D is inappropriate since constructors are not called in the context of test execution, which can lead to inconsistent test states.