• Ranjan Saha
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
@isTest
public class ValidateTestStartMethod {
 static testmethod void method1() {
     
    for (Integer i= 0;i<95;i++) {
         Account[]acctlist = [select id from Account limit 1];
     }
     
     Test.startTest();
     for (Integer i=0;i<=10;i++) {
         Account [] ac = [select id from Account limit 1];
     }
     Test.stopTest();
 }

I completely understand as per best practices we should not write any query inside the for loop. Here I just wanted test the purpose of Test.StartTest and Test.StopTest methods. 

As per Salesforce document, Test.StartTest allocates fresh set of governor limits. But unfortunately above code failing due to SOQL query limit exception. Any thoughts, why is it so ?  Thanks in advance :)

User-added image



Regards,
Dipak Nikam