nerdexam
Salesforce

CRT-450 · Question #137

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?

The correct answer is C. Use Test.getStandardPricebookid ( ) to get the standard price book ID. See the full explanation below for the reasoning.

Question

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?

Options

  • AUse Test.loadData ( )and a static resource to load a standard price book
  • BUse @TestVisible to allow the test method to see the standard price book.
  • CUse Test.getStandardPricebookid ( ) to get the standard price book ID.
  • DUse @IsTest (SeeAllData=True) and delete the existing standard price book

How the community answered

(25 responses)
  • A
    4% (1)
  • B
    16% (4)
  • C
    72% (18)
  • D
    8% (2)

Community Discussion

No community discussion yet for this question.

Full CRT-450 Practice