nerdexam
Salesforce

PDII · Question #206

The test method above tests in Apex trigger that the developer knows will make a lot of queries when a lot of Accounts are simultaneously updated to be customers. The test method fails at the Line…

The correct answer is C. Add Test.startTest() before Line 18 of the code and add Test.stopTest() after line 18 of the code. See the full explanation below for the reasoning.

Question

The test method above tests in Apex trigger that the developer knows will make a lot of queries when a lot of Accounts are simultaneously updated to be customers. The test method fails at the Line 20 because of too many SOQL queries. What is the correct way to fix this?

Options

  • AChange the DataFactory class to create fewer Accounts so that the number of queries in the
  • BAdd Test.startTest() before and Test.stopTest() after both Line 7 of the code and Line 20 of the
  • CAdd Test.startTest() before Line 18 of the code and add Test.stopTest() after line 18 of the code
  • DReplace most of the Apex Trigger with Process Builder processes to reduce the number of queries

How the community answered

(30 responses)
  • A
    7% (2)
  • B
    13% (4)
  • C
    77% (23)
  • D
    3% (1)

Community Discussion

No community discussion yet for this question.

Full PDII Practice