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
Lotzi11Lotzi11 

Too Many SOQL Queries: 101

I am currently working on getting test cases to work so I can start to alter the main code, however whenever I try to run my test cases they fail and I get the following error "too many SOQL queries: 101."  When I check to see where this error is occuring it points to the top of the program at "@isTest(SeeAllData=true)."  What does this mean , and how would I go about fixing the problem?
crop1645v2crop1645v2
Well, any given transaction may only execute 100 SOQL queries.  Most common culprit is you are doing SOQL within a for loop. This is easy to spot by simply running with the debu log on and tracing the SOQL calls versus trigegrs/controlelrs or whatever you have under test.

Check out SFDC best practices under SOQL and bulkification - there are dozens of articles on this topic

It is possible this is not the issue and you simply have a too complex testmethod and need to break it into multiple methods.
Rahul SharmaRahul Sharma
seeAllData is by default false. BNy making it true, Test class relies on org's actual data. 
So, We should always create our test data in test class and never rely on the org's data.

Hope this helps!