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
Paras JainParas Jain 

I am deploying my Trigger and test classes to Production--Error

I am deploying my Trigger and test classes to Production but i am getting the error  too much soql queries 101....and the test classes that are already in production are failing ... and as i have checked the error lines of Test class the method of class is callling and there is no problem of anywhere of SOQL query.. please explain me what happening?
ManojjenaManojjena
Hi Paras,

Try to wrap test methods with Test.startTest and Test,stopTest method to avoid 101 SOQL Limit .

Avoid more DML statement for a single object using foe loop which will solve your problem ,
Like ,
 
Account acc =new Account ();
   acc.Name='Test';
   insert acc;
Account acc1 =new Account ();
   acc1.Name='Test1';
   insert acc1;
Account acc2 =new Account ();
    acc2.Name='Test2';
   insert acc2;

try like below 
List<Account> accList=new List<Account>();
for(Integer i=0;i<=200;i++){
   Account acc=new Account();
   acc.name='TestAccount'+i;
   accList.add(acc);
}
insert accList;
Let me know if it helps 

Thanks
Manoj



 
Suraj PSuraj P
Check if you have any Process Builder processes defined in production. As of now, they are not designed to handle bulk requests and could be causing the problem.
Beer NutthawanBeer Nutthawan
Hi Paras

Can you show us your test class?