12

We are in process of deploying a project to PROD and found that test coverage is coming up less then 75%.

There are some triggers we have merged into single trigger.

Question is: whether the inactive triggers are calculated to get average test coverage ?

Documentation says that Comments and @isTest are not counted against coverage. What about inactive triggers?

10

The inactive triggers are counted against code coverage for sure and also there is no way to get coverage for these as this is considered dead code if its not used .

One work around could be to activate these triggers if this has to be kept for future process and use custom setting to decide to run at run time or stop them .

If these are inactive and no more needed archive this and store code in some repo and get rid of them from production .

7

Yes, Inactive triggers are counted against code coverage. Possible workarounds:

  1. You can comment the trigger body
  2. Create test class for inactive trigger so that when you want to activate it you will not run into code coverage issues
  3. Have a custom setting (boolean field) that determines whether the logic inside the trigger need to execute. So that you can keep the trigger active and you need to have a test class for this.

Hope this helps!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.