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

Which two statements are true about using the @testSetup annotation in an Apex test class? Choose 2 answers
A . a method defined with the @tetestSetup annotation executes once for each test method in the test class and counts towards system limits.
B . Records created in the test setup method cannot be updated in individualtest methods.
C . 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 cg5lsTest(SeeAIIData=True) annotation is used.

Answer: C, D

Explanation:

Option C: In a test setup method, test data is inserted once and made available for all test methods in

the test class.

True.

The @testSetup method runs once before any test methods in the class.

Test data created in this method is available to all test methods, promoting code reuse and efficiency.

Reference: Using Test Setup Methods

Option D: The @testSetup annotation is not supported when the @isTest(SeeAllData=True)

annotation is used.

True.

The @testSetup method is not supported in test classes annotated with @isTest(SeeAllData=true). Using SeeAllData=true accesses existing organization data, conflicting with the isolation provided by @testSetup.

Reference: Test Setup Methods Restrictions

Option A: A method defined with the @testSetup annotation executes once for each test method in

the test class and counts towards system limits.

False.

The @testSetup method executes only once per test class, not once per test method. It does count towards the per-test-class limits but improves overall test performance.

Reference: Test Setup Methods Execution

Option B: Records created in the test setup method cannot be updated in individual test methods.

False.

Records created in a @testSetup method can be queried and modified within individual test methods.

This allows tests to manipulate shared test data as needed.

Reference: Accessing Test Setup Records

Conclusion:

The correct statements are C and D, as they accurately describe the behavior and restrictions of the @testSetup annotation.

Latest DEX-450 Dumps Valid Version with 456 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments