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
Rakesh ERakesh E 

can we write multiple test classes to cover a single class

Hi,

 

actually i have a Apex controller which is huge and which has many scenarios with more SOQL queries. when i write test cases in a single test class to test all the scenarios i am getting "Too Many SOQL quiries limit exception". i dont know why salesforce treats all test methods in a single class as a single transaction. 

 

so to compensate this i am thinking of writing another test class to test some scenarios. will this work correctly. is this approach a good practice?

 

please let me know if anyone faced same problem in test classes. help me to solve the problem.

 

Regards,

Rakesh

gbu.varungbu.varun

Hi Rakesh,

 

In a single test class you can create multiple test methods on the basis of different scenarios.

 

Thanks,

Varun

Bhawani SharmaBhawani Sharma
Nope, this is not a good practice. Instead if that, you can break your test code in different methods. Also make sure to use Test.startTest and Test.stopTest() method. This reset the limits for test transaction.