Salesforce Platform Developer I (legacy) — Question 101

A Developer wants to get access to the standard price book in the org while writing a test class that covers an OpportunityLineItem trigger.
Which method allows access to the price book?

Answer options

Correct answer: A

Explanation

The correct answer is A because Test.getStandardPricebookId() is specifically designed to retrieve the ID of the standard price book in test contexts. Options B and C are incorrect as they either manipulate data inappropriately or do not directly provide access to the standard price book. Option D is also incorrect since @TestVisible does not grant access to data that is not otherwise visible in the test context.