nerdexam
Salesforce

PDII · Question #329

A developer wrote a class named AccountHistoryManager that relies on field history tracking. The class has a static method called getAccountHistory that takes in an Account as a parameter and…

The correct answer is C. Use Test.isRunningTest() in getAccountHistory() to conditionally return fake AccountHistory. See the full explanation below for the reasoning.

Question

A developer wrote a class named AccountHistoryManager that relies on field history tracking. The class has a static method called getAccountHistory that takes in an Account as a parameter and returns a list of associated AccountHistory object records. The following test fails:

What should be done to make this test pass?

Exhibit

PDII question #329 exhibit

Options

  • AThe test method should be deleted since this code cannot be tested.
  • BCreate AccountHistory records manually in the test setup and write a query to get them.
  • CUse Test.isRunningTest() in getAccountHistory() to conditionally return fake AccountHistory
  • DUse @isTest (SeeAllData=true) to see historical data from the org and query for AccountHistory

How the community answered

(24 responses)
  • A
    13% (3)
  • B
    4% (1)
  • C
    75% (18)
  • D
    8% (2)

Community Discussion

No community discussion yet for this question.

Full PDII Practice