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

best pratice to avoid governor limit in unit test

My unit test reach the governor limit of 100 SOQL query.


what is the best practice to divide the unit test and reset the governor limit to 0 ? ( in the same time I want to keep my the account opportunity ... that i have create at the beginning of my test ).







Best Answer chosen by Admin (Salesforce Developers) 



Please post a bit of code.. there are some common gotcha's that get almost everyone in the beginning. Unit tests should be just that, they should test one method of a class. You can handle all your data initialisation in a static method that your unit test method calls.