Exam PDII Topic 1 Question 137 Discussion

Actual exam question for Salesforce's PDII exam
Question #: 137
Topic #: 1
Refer to the test method below:

The test method tests an 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?

Suggested Answer: D Vote an answer

The correct way to fix this is to add Test.startTest() before and add Test.stopTest() after Line 18 of the code.
This will reset the governor limits for the code that executes between these two methods, and allow the test to run without hitting the SOQL query limit. The Test.startTest() and Test.stopTest() methods are used to test code that makes a lot of queries or calls asynchronous methods12. By using these methods, the developer can isolate the code that needs more resources and verify that it does not exceed the governor limits.
:
Using Limits, startTest, and stopTest | Apex Developer Guide | Salesforce Developers Test.StartTest & Test.StopTest - Salesforce Developer Community Why would a developer use test startTest and test stopTest in Salesforce? | ForceTalks

by Joanne at Jul 15, 2026, 11:09 PM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
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.

0
0
0
10