Salesforce Platform Developer I (legacy) — Question 198

Which two statements are true about using the @testSetup annotation in an Apex test class? (Choose two.)

Answer options

Correct answer: A, D

Explanation

The correct answers are A and D. Answer A is correct because the @testSetup annotation cannot be used when the @isTest(SeeAllData=True) annotation is present, as it would conflict with the test data management. Answer D is accurate since the purpose of the @testSetup method is to insert test data once and share it across all test methods, enhancing efficiency. Answers B and C are incorrect; B is wrong because records from the setup can be updated in test methods, and C is incorrect because the @testSetup method executes only once for the entire test class, not once per test method.