[SalesForce] Production code coverage error on deployment but in sandbox coverage is above 75%

I'm trying to deploy a change set to my production org. I'm running only tests for the test classes I'm including in the package. But there is still one class with coverage below 75%. In my sandbox, the class coverage is above 75%, but in sandbox it is a lot below that. I've tried even copying the production class to the sandbox as is and creating a test class for it with coverage above 75%, and uploading a change set with just that class and the test, but it still fails to cover at least the 75% of the code.

I've read here about deleting bad class coverage records, but running all the tests is not an option for me right now because some changes were deployed after my sandbox refresh, so my sandbox is not exactly the same as production now.

I would like to know if I can delete only the class coverage record for the class that has the problem. The method explained in the link doesn't show how to identify specific classes.

Why if I run only selected tests, which I have seen covers all the class, do I still get the not enough coverage error?

Best Answer

Deployment to production requires 75% coverage and no test failures; accordingly, all unit tests are automatically run as part of deployment or validation to deployment. You will need to resolve your problem(s) before you can deploy to production.

Edit: I'd consider just creating a new developer sandbox, using the change set to deploy to that; this should make it easier to isolate the problem with a more recent version sandbox to work with.

Related Topic