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
I am new to Salesforce.comI am new to 

Test Methods

What is the need of Test.start() and Test.stop() methods,without using these methods what  issue i will get?






Best Answer chosen by Admin (Salesforce Developers) 

Test.start() takes you into a new context.  When you setup a load of test data, execute SOQL calls against that data to extract ids etc, you will consume some of the limits for DML, SOQL etc.  By executing Test.startTest() you effectively reset all those limits so that your test code starts from scratch.  This allows you to be sure that any governor limits problems are entirely down to your code.


Test.stopTest() takes you back to the original context, but more importantly causes all asynchronous processing scheduled by your test to execute.  So if you have @future calls to test and you don't execute this method then they won't run.