+ Start a Discussion
Mike FuchsMike Fuchs 

Deactivating a Bad Test Class and Bad Trigger in Production

Please tell me if this will cause an issue:
  1. Using Force.com IDE delete a bad test class (associated with a trigger in step 2) by changing status to deleted in the XML file and deploy from Force.com IDE
    1. All Apex tests will run in Production and when they validate will delete the test class
  2. Using Force.com IDE deactivate/delete a bad trigger in Production by changing the status in the XML file to either inactive or deleted and deploy from Force.com IDE
    1. All Apex tests will run in Production and when they validate will inactivate/delete the trigger
My question is after deleting the Test Class in Step 1, when I try to deactivate my trigger will the Apex Tests try to "test my trigger" before deactivating it and won't be able to do so because of a missing test class.  I can't deactivate the trigger (Step 2) first, as it runs the bad test class and fails there. Please let me know.  Thank you!
Mike FuchsMike Fuchs
To summarize...can I decactivate or delete a trigger in Production that has no code coverage?
UC InnovationUC Innovation
Yes, you should be able to do so.  As long as you have enough test coverage without the trigger you want to delete, it should be fine.  Since the trigger you want to delete has no code coverage, that implies you have enough test coverage in production without that trigger.

Just as an aside, that's the only way you can delete a trigger.  If you have a test class that relies on a trigger, you cannot delete the trigger without first deleting the test class as the test class depends on the trigger.  You can only delete a test class if the other test classes give enough code coverage afterwards.  Once you delete the test class, the trigger that the test class relies on can now be deleted because it's not referenced anywhere anymore, and it doesn't contribute to the code coverage.
You will need to use an IDE or Workbench to delete the trigger from Production.

Follow these links for instructions:
There are a number of ways to stop a trigger to run.  I've consolidated the list.  Read here

Mike FuchsMike Fuchs
Hi - surrpised to see this question had sudden activity a year and a half after I posted in.  Needless to say, this issue was resolved back then doing the exact method I posted in the original question.  Thank you