+ Start a Discussion
Shruthi GM 4Shruthi GM 4 

I am getting too many soql queries error when am running the test classes.

How to get rid of this error?
Can anyone please suggest way to remove this error?!


Thanks inadvance.
BALAJI CHBALAJI CH
Hi Shruthi,

Maybe your Test Class is not Bulkified. Make sure that you dont have SOQL Queries inside For loops or any other iterations.
You can share your test Class for better solution.

Best Regards,
BALAJI
Nupoor SharmaNupoor Sharma
Hi Shruthi,

As recommended by Balaji, the first thing to do is to bulkify the code. Additionally you can use Test.startTest() and Test.stopTest() methods to expand the number of SOQLs you can use in a Test method. 

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_tools_start_stop_test.htm

Different test cases can be broken down into multiple test methods for better results.
Leanbridge TechnologiesLeanbridge Technologies
stopTest() you get 2X governer limits. ... with Ids mentioned in the List 'accIds', I got the Too many SOQL queries error on running the test class.