Salesforce Platform Developer I (legacy) — Question 34
A developer wants multiple test classes to use the same set of test data.
How should the developer create the test data?
Answer options
- A. Reference a test utility class in each test class.
- B. Define variables for test records in each test class.
- C. Create a Test Setup method for each test class.
- D. Use the SeeAllData=true annotation in each test class.
Correct answer: A
Explanation
The correct answer is A because referencing a test utility class allows multiple test classes to access the same set of data efficiently, promoting reusability. Options B and C do not allow for shared data across classes, as defining variables or creating setup methods would require duplication. Option D is not ideal for maintaining data isolation and can lead to unintended consequences in tests.