+ Start a Discussion
Med Usa1Med Usa1 

Test Class For A Trigger



I have on Opportunity a trigger and a test class for a special case (created and deployed for a long time by someone else).


I have created another trigger (always on opportunity) to do totaly something else and I created a test class to cover the code. (100% of coverage)


When I want to deploy my new trigger and its test class in production I have this error :

Failure Message: "System.LimitException: Too many query rows: 50001", Failure Stack Trace:...


It tries to test not my test class but the other test class of the old trigger.


I don't understand why the other Test Class is executed and for the wrong trigger ? Why don't it take the good test class ?

Could you explain to me and give me a solution for this pb ?


Thank you.


When you are deploying any artifact (page/class/trigger) to any other Salesforce Org, only the artifacts which are being deployed are not validated but it also validates all the other existing artifacts. If any issues in the existing ones, it throws a failure. 


Can u post  your code here?




Since both the triggers are on Opportunity, when your new test case saves an opportunity, the old Opportunity trigger as well as the new Opportunity trigger will get invoked.