-1

I have a AccountTest class which run with more than 75% coverage in dev env. But when I tried same class in a another sandbox without any code change give this too many soql error. Can someone have idea why the issue comes ?

6
  • 1
    You'll have to show us your test as well as the code it's testing to get any specific advice. For now, about all we can say is "look for any queries inside of loops, and get them out of the loops"
    – Derek F
    Jun 22 at 16:38
  • Also, using seeAllData=true (which you should never use unless you know for certain that it's required for the feature you're testing) is an easy way to get differing results in different orgs.
    – Derek F
    Jun 22 at 16:41
  • Your code coverage has nothing to do with "Too many SOQL" errors. Don't think of your Test class as stand-alone. First of all, the class that is tested might be very different on your two orgs even if the Test class is the same - e.g. one not having any SOQL at all, the other lots. But even the class tested is not alone: It can call other classes; triggers and flows might get involved, Custom Metadata types provide a very different environment etc. You see - such errors can come from very different directions. Jun 22 at 17:44
  • There are no any loops. Thank you DerekF and Felix van Hove i will look into with your information.
    – Basu
    Jun 22 at 18:11
  • Are you using Test.startTest() and stopTest() in your test methods? These give you a fresh set of limits with every test. Differences in Triggers/Classes usually are what cause such an issue.
    – stackasaur
    Jun 22 at 20:59

0

Browse other questions tagged or ask your own question.