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
sandy ksandy k 

I have trigger on Opportunity object and batch class which updates the same Opportunity object, how can I write test class only for batch class

Hi Guys,

I have trigger on Opportunity object  with events insert,update and delete and batch class which updates the same Opportunity object, how can I write test class only for  batch class.

When I am writing test class coverage only for batch class and inserting test Opportunity data, the test code covering trigger also and throw error System.LimitException: Too many SOQL queries: 101. How can I skip executing trigger code from test class execution which should only cover batch class. How can I achieve this

 
AnkaiahAnkaiah (Salesforce Developers) 
Hi Sandy,

Have you tried with Test.startTest() &  Test.stopTest() in your test menthod?
Test.startTest();

        insert Opp;

   Test.stopTest();
Thanks!!