A developer notices the execution of all the test methods in a class takes a long time to run, due to the initial setup of all the test data that is needed to perform the tests. What should the developer do to speed up test execution?
A.
Define a method that creates test data and annotate with @testSetup.
B.
Define a method that creates test data and annotate with @createData.
C.
Ensure proper usage of test data factory in all test methods.
Using the @testSetup annotation to define a method that creates test data before the tests run can significantly speed up test execution by reducing the setup time for each test method in the class. This method runs once before any test method in the class and can be used by all test methods.
[References: Apex Developer Guide - Reducing Test Data Creation]
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit