0

I have a test class where i am getting 'Too many SOQL Queries : 101' error. I looked up my batch code for any Query violations in FOR loop or DML operations in FOR loop but i couldn't find some. I found one of my objects is not inserted in Test class which i created as a heap. I don't get any errors related to that but instead having the error 'Too many SOQL Queries : 101'

What would be the cause? Help would be appreciable Thanks in advance

1
  • 1
    Please add the relevant code Dec 31, 2019 at 7:52

2 Answers 2

1

Welcome to Salesforce stackexchange community.

By using the Test.startTest() & Test.stopTest() you reset limits.

To fix this issue what you will have to do is:

Optimize and see if you can reduce the queries in triggers and helper classes & Reduce the number of objects you are inserting

In worst case you can use SeeAllData = true.

0

You can try below options -

1) When you are creating test data in the testsetup method , make sure insertion of test records doesn't fire a trigger. You can switch off the trigger or the handler class being called, just before insert dml statement. (You don't want to test any logic here, rather you need records to be created which can be used in test method)

2) You must always use Test.starttest() and Test.stoptest() in each of the test methods to reset the limit.

Not the answer you're looking for? Browse other questions tagged .