[SalesForce] Commenting out unused class tells me I have 0% code

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

Best Answer

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.