2

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?

1
  • Are you using test data?
    – unidha
    Aug 9, 2016 at 6:56

3 Answers 3

3

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.

1

Possible reasons for this problem are,

  1. One or more validation rules on objects that are inserted in test class which are not in present in Sandbox.
  2. One or more Workflow rules with field update action on objects that are inserted in test class which are not in present in Sandbox.
  3. One or omre processes in Process builder which are updating fields and not present in Sandbox.

Check all three cases and you will sort the your problem on your own.

0

If you are using SeeAllData=true in any of your tests, data in your sandbox may be using certain paths in your code flow that your production data is not using.

To avoid this, don't use SeeAllData=true and generate your test data as part of the test class.

You must log in to answer this question.

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