ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 403 - Certified Platform Developer II discussion

Report
Export

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?

A.
Answers
A.
B.
Answers
B.
C.
Answers
C.
D.
Answers
D.
Suggested answer: D

Explanation:

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

asked 23/09/2024
Sandeep Ramakrishnan
49 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first