function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JayDP123JayDP123 

Test.Starttest() question

Hi,

 

I am just wondering if someone can explain when I am supposed to use Test.StartTest() and Test.StopTest() ? 

 

If I have a testmethod already, and the @istest notation, are the aforementioned methods necessary to perform a test? Can I run the test without them? When should I be starting-stopping? 

 

Thanks!!

Best Answer chosen by Admin (Salesforce Developers) 
SeAlVaSeAlVa

High level, lets say that before calling startTest, you should create all the information required for your test.

 

Then you call startTest and the limits get reset (Number of queries, dmls, etc.), so you can Test if your code will be able to handle batches, for example, etc.

 

 

All Answers

SeAlVaSeAlVa

High level, lets say that before calling startTest, you should create all the information required for your test.

 

Then you call startTest and the limits get reset (Number of queries, dmls, etc.), so you can Test if your code will be able to handle batches, for example, etc.

 

 

This was selected as the best answer
JayDP123JayDP123

Aha I see. 

 

Thanks to you both!