Code coverage failure: Average test coverage across all Apex Classes and Triggers is below the required percent: meaning and how to fix it

Deployment Checked against the official docs on Source: SOAP API Developer Guide: Core Data Types, StatusCode

Quick answer

Code coverage failure: Average test coverage across all Apex Classes and Triggers is below the required percent: A deployment to production that runs tests did not reach the required org-wide Apex test coverage of 75 percent. Start with: Write tests for the classes with the lowest coverage; assert behavior, not only coverage.

Typical message: Code coverage failure: Average test coverage across all Apex Classes and Triggers is 62%, at least 75% required

Cause

A deployment to production that runs tests did not reach the required org-wide Apex test coverage of 75 percent.

How to fix Code coverage failure: Average test coverage across all Apex Classes and Triggers is below the required percent

  1. Write tests for the classes with the lowest coverage; assert behavior, not only coverage.
  2. Run all local tests in a sandbox and check coverage per class before deploying.
  3. Check that failing tests are not lowering coverage.

Have a different message? Paste it into the error decoder, which matches it against 45 common Salesforce errors in your browser.

Frequently asked questions

What does Code coverage failure: Average test coverage across all Apex Classes and Triggers is below the required percent mean in Salesforce?

A deployment to production that runs tests did not reach the required org-wide Apex test coverage of 75 percent.

How do I fix Code coverage failure: Average test coverage across all Apex Classes and Triggers is below the required percent?

1. Write tests for the classes with the lowest coverage; assert behavior, not only coverage. 2. Run all local tests in a sandbox and check coverage per class before deploying. 3. Check that failing tests are not lowering coverage.

More Deployment errors

SFDX Talk is unofficial documentation. It is not affiliated with, endorsed by, or sponsored by Salesforce, Inc. Message text varies slightly by release and context, so confirm against the official page before relying on it.