+ Start a Discussion

Code Coverage Can't Deploy to Production

In production, code coverage is showing 83%. In sandbox, it is showing 75%. I have just 1 apex class and associated test class I am trying to deploy to production, but it fails saying only 30% coverage in production.

The apex class I am trying to deploy has 90% coverage, why can't I deploy this class and associated test class to production?

Raj VakatiRaj Vakati
The reason might be 
  1. check that all test classes are creating their own test data and do not rely on org's data. 
  2. Check All the Test class in prod vs sandbox
  3. Make sure if you are refering any settings in test class  , those avaibale in prod 
  4. Is your test class dependent on data or custom settings that only exist in your sandbox?
  5. Do you have extra classes or code in production? This can even be in the form of installed packages, etc.
  6. Test coverage is calculated based on the total number of tested Apex statements (or lines) divided by the total number of Apex statements in your organization.