Salesforce Platform Developer I (legacy) — Question 206

A developer is writing tests for a class and needs to insert records to validate functionality.
Which annotation method should be used to create records for every method in the test class?

Answer options

Correct answer: C

Explanation

The correct answer is C, @TestSetup, because this annotation is specifically designed to create test records that are available for all test methods in the class. The other options do not serve this purpose; @StartTest is used to reset governor limits, @PreTest is not a valid annotation, and @isTest(SeeAllData=true) allows access to all data but does not create new records.