Salesforce Platform Developer I (legacy) — Question 247
A developer at AW Computing is tasked to create the supporting test class for a programmatic customization that leverages records stored within the custom object, Pricing_Structure__c. AW Computing has a complex pricing structure for each item on the store, spanning more than 500 records.
Which two approaches can the developer use to ensure Pricing_Structure__c records are available when the test class is executed? (Choose two.)
Answer options
- A. Use the Test.loadTest() method.
- B. Use the @IsTest(SeeAllData=true) annotation.
- C. Use a Test Data Factory class.
- D. Use without sharing on the class declaration.
Correct answer: A, C
Explanation
The correct answers, A and C, provide strategies for creating test data within the test context, ensuring that the necessary records are available. Option B is incorrect because using @IsTest(SeeAllData=true) is generally discouraged as it can lead to tests that depend on existing data, while option D does not relate to data accessibility in tests.