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
fiona gentryfiona gentry 

What Changes Is Needed to Decrease the Long Running Tests,Currently its 2mins

Dear Gurus,

What Changes Is Needed in the test class below  to Decrease the Long Running Tests,Currently its 2mins
 
here is Test class  (https://docs.google.com/document/d/1zf91sGkndxaUn31nDdwp1LbSwlnUBAeI0UwM-BAPiUs/edit?usp=sharing)

and here is apex class (https://docs.google.com/document/d/1aQN7dHCkH9xsAqJOj0IHUFPlpdyG_nOKW9WMXX1y9W0/edit?usp=sharing)

Your help is highly appreciated
Regards,
Fiona


 
Best Answer chosen by fiona gentry
SwethaSwetha (Salesforce Developers) 
HI Fiona,
Hope you are doing well!

I have checked the drive links you posted. Since the code is huge and requires an understanding of your implementation, it might not be possible to provide exact edit suggestions. However, the below articles give a good insight into how you can optimize the code so that execution time can be improved

https://salesforce.stackexchange.com/questions/8346/how-to-reduce-the-test-class-execution-time-while-deploying
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_best_practices.htm
https://salesforce.stackexchange.com/questions/171683/how-to-improve-code-quality-in-test-class

I see there are several SOQLs in your classes.You might want to have the qualifying fields indexed as per  https://help.salesforce.com/articleView?id=000336230&type=1&mode=1 to improve the performance.

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you