Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam Certified Platform Developer II topic 1 question 348 discussion

Actual exam question from Salesforce's Certified Platform Developer II
Question #: 348
Topic #: 1
[All Certified Platform Developer II Questions]

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?

  • A. The test method should be deleted since this code cannot be tested.
  • B. Create AccountHistory records manually in the test setup and write a query to get them.
  • C. Use Test.isRunningTest() in getAccountHistory() to conditionally return fake AccountHistory records.
  • D. Use @isTest (SeeAllData=true) to see historical data from the org and query for AccountHistory records.
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Vikas_08
3 weeks, 1 day ago
ANSWER is D Explanation- To make the test pass, @isTest(SeeAllData=true) should be used to allow the test to access historical data from the org. This is required because field history tracking data is not copied to a test context, so you need to allow the test to access live data to assert against it.References: Apex Developer Guide - IsTest Annotation
upvoted 1 times
...
M4JK3LSON
4 months, 3 weeks ago
C can be good answer, because standard field tracking mechanism do not apply for apex tests
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...