In trying to get better coverage, I want to retire unused classes that have low coverage. When I try to deploy a commented out version of the class, I get an error:

Your organization's code coverage is 0%. You need at least 75% coverage to complete this deployment. Also, the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.

I don't see this as possible. If I try to deploy an updated class that still has a body, I get an org percentage that makes sense (73%, which I am trying to improve).

Does anyone understand why I can't retire these classes? Thanks

2 Answers 2


When you deploy code to production, all of your tests are run, and validation of overall code coverage takes place, as well as by trigger. Each trigger must be exercised in some way by a unit test, otherwise this validation will fail. I think your first step is writing some unit tests for the trigger(s) in question. Also, if you wish to delete classes or triggers, you can deploy those deletions by deploying your entire classes and triggers directories, minus the deleted metadata, from your sandbox. Beware though that your sandbox accurately represents production, because this will overwrite all classes and trigger in production with what is in your sandbox.

  • I have tests for all the triggers in question. They all have various degrees of coverage when I try to deploy a new class. it is only when I try to deployed a commented out class that I see them as having 0.
    – jaw999
    Commented Oct 20, 2014 at 15:37
  • Have you looked to see where the classes are being used? It sounds as though these classes are perhaps being called from triggers or other classes that rely on them. When they're not available, your coverage drops because other test classes fail because the code isn't there when it's called upon to run.
    – crmprogdev
    Commented Oct 20, 2014 at 15:45
  • I will look but I am not sure how removing class 'ABCsort' would make trigger 'LinkeXYZtoPDQ' suddenly show no coverage.
    – jaw999
    Commented Oct 20, 2014 at 15:48
  • The overall code coverage is a red herring, and appears to be false in this case. What would seem to be the problem is a trigger that isn't being exercised at all.
    – greenstork
    Commented Oct 20, 2014 at 15:58
  • greenstork, this appears correct. Can you elaborate a little? I would be happy with a class not being exercised - I don't want it hanging out in my org to potentially fire
    – jaw999
    Commented Oct 21, 2014 at 13:11

Test Classes referencing the deleted class also need to be deleted/ changes.

  • While this solved the problem, it does not change the fact the error messages are terribly confusing and unhelpful.
    – jaw999
    Commented Oct 22, 2014 at 14:20
  • I had a similar problem: I wanted to deploy some classes after I deleted a deprecated class in my sandbox. Deployment said I have 0% coverage (which is obviously wrong). After deleting the deprecated class in production, the deployment succeeded. Thanks for this hint.
    – georg w.
    Commented Nov 20, 2014 at 16:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .