Plat-Dev-201 practice question 2 of 30

Which two statements are true about using the @testSetup annotation in an Apex test class? Choose 2 answers

Full set: 204 questions
Answer options
A: Records created in the test setup method cannot be updated in individual test methods.
B: In a test setup method, test data is inserted once and made available for all test methods In the test class. Correct answer
C: A method defined with the @testSetup annotation executes once for each test method in the test class and counts towards system limits.
D: The @testSetup annotation is not supported when the @isTest(SeeAllData=True) annotation is used . Correct answer
Correct Answer:
B. In a test setup method, test data is inserted once and made available for all test methods In the test class.; D. The @testSetup annotation is not supported when the @isTest(SeeAllData=True) annotation is used .
Explanation

@testSetup methods run once per test class, inserting common test data that every test method can access, saving governor limits. They cannot be used in a class annotated with @isTest(SeeAllData=true); that combination is explicitly unsupported.

Why Incorrect

A. Records can be updated inside a test method; updates are isolated to that method.
C. testSetup executes only once per class, so its DML counts once, not once per test method.

References

1. Apex Developer Guide, “Test Setup Methods” (v59.0) – runs once, data shared, cannot be used with SeeAllData=true.

2. Apex Developer Guide, “Isolation of Test Data” (v59.0) – explains visibility and mutability of setup records within individual test methods.

Scroll to Top