nerdexam
SalesforceSalesforce

PDI · Question #216

PDI Question #216: Real Exam Question with Answer & Explanation

The correct answer is A: Use a Test Date Factory class.. When testing Apex code that relies on a large number of existing records, developers can use a Test Data Factory to programmatically create the necessary test data or leverage the Test.loadData() method to import data from a static resource.

Submitted by chen.hong· Apr 18, 2026Testing, Debugging, and Deployment

Question

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 2 answers

Options

  • AUse a Test Date Factory class.
  • BUse the @raTeat (seeAllData=true) annotation.
  • CUse the Test. leadtear{} method,
  • DUse without shering on the class declaration.

Explanation

When testing Apex code that relies on a large number of existing records, developers can use a Test Data Factory to programmatically create the necessary test data or leverage the Test.loadData() method to import data from a static resource.

Common mistakes.

  • B. The @isTest(seeAllData=true) annotation is deprecated and generally discouraged because it makes tests less reliable by exposing them to potentially inconsistent or changing organizational data, rather than isolated test data.
  • D. Using without sharing on a class declaration affects the enforcement of sharing rules for the class when executed, but it does not provide a mechanism to create or load test data into the test context.

Concept tested. Apex test data creation methods

Reference. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_data_make_data.htm

Topics

#Apex Testing#Test Data#Test Data Factory#Test.loadData

Community Discussion

No community discussion yet for this question.

Full PDI PracticeBrowse All PDI Questions