Salesforce Certified Platform Developer II — Question 121
A developer needs test data for Apex test classes.
What can the developer use to provide test data to the test methods? (Choose two.)
Answer options
- A. List<sObject> Is = Test.loadData (Lead.sObjectType, 'myTestLeads');
- B. myDataFactory.createTestRecords (10)
- C. Database.createTestRecords (10)
- D. List<sObject> Is = Test.loadDat (Lead.sObjectType, $Resource + 'myTestLeads');
Correct answer: A, B
Explanation
The correct answers are A and B. Option A allows loading test data directly from a static resource, which is useful for managing test data in a structured manner. Option B uses a custom data factory method to create a specified number of test records. Options C and D are incorrect because C does not provide a way to load predefined test data, and D contains a typo in the method name, making it invalid.