MemberFebruary 18, 2020 at 3:44 pm
Why we use Test.startTest() and Test.stopTest() in Test Class in Salesforce ?
MemberFebruary 19, 2020 at 6:23 am
The startTest method marks the point in your test code when your test actually begins. Each test method is allowed to call this method only once. All of the code before this method should be used to initialize variables, populate data structures, and so on, allowing you to set up everything you need to run your test. Any code that executes after the call tostartTest and before stopTest is assigned a new set of governor limits.
So, every time you use the test.start and test.stop in your test method, new set of governor limits are assigned to the code executing between them. If you don't use them in your testmethods there may be chances of your test methods over shooting the set governor limits.
Log in to reply.