You need to sign in to do that
Don't have an account?
starttest and stoptest is not resetting the limits, see the following code
@isTest(SeeAllData=True)
public class TestStatAndStop {
public static testmethod void MyMothod()
{
for (integer i =1; i<=90;i++)
Contact b1 = [select id from contact limit 1];
Test.startTest();
for (integer i1 =1; i1<=99;i1++)
{
Account b = [select id from account limit 1];
}
Test.stopTest();
}
}
Strange. I just tried this on my dev org and also got a limit exception thrown.
Generally speaking, unit tests are written to call external methods / code and test them, not to test arbitrary executions or SOQL queries. That being said, I updated your class to call a method, and the governor limit resolved itself:
Furthermore, it appears if you call any external method, even Limits.getQueries(), the governor limits are reset.
All Answers
Hi,
Why are you querying inside loop. Do not write any query inside for loop , it will definitely hit limit.
Regards,
Grazitti Team
Web: www.grazitti.com
Email: sfdc@grazitti.com
Strange. I just tried this on my dev org and also got a limit exception thrown.
Generally speaking, unit tests are written to call external methods / code and test them, not to test arbitrary executions or SOQL queries. That being said, I updated your class to call a method, and the governor limit resolved itself:
Furthermore, it appears if you call any external method, even Limits.getQueries(), the governor limits are reset.