A developer needs to create a baseline set of data (Account, Contacts, Products, Assets) for an entire suite allowing them to test independent requirements for various types of Salesforce Cases.
Which approach can efficiently generate the required data for each unit test?
A. Use &TestSteup with a void method.
B. Create test data before Test.startTest in the unit test.
C. Create a mock using the Stub APL.
D. Add $ IsTest (seeAllDatatrue) at the start of the unit test class.
A. Use &TestSteup with a void method.
Explanation:
@TestSetup methods are used in test classes to create test data once and share it across all test methods in the same class.
This improves efficiency and reduces duplication of data creation code.
Ideal for baseline data like Accounts, Contacts, Products, and Assets that are common across test methods.