If I am deploying test classes from sandbox to production, how does Salesforce calculate the code covergae?

For example:
If I have 5 classes with 5 test classes, should the overall average coverage be greater than 75? Or should each test class have at least 75 percent code coverage?

2 Answers 2


If you deploy with Run All Tests, then you only need 75% average across all classes (some individual classes may be less than 75%), and 1% coverage on all triggers. If you deploy with Run Specified Tests, then each class covered must individually meet or exceed 75% coverage. So, both statements in your question are true, depending on the mode you choose to deploy with.

  • 1
    Thanks sfdcfox. Your help for so many of us is extremely appreciable. Poeple like you share knowledge and help others grow. Thankuuuuu
    – user59223
    Aug 19, 2018 at 4:44

Code coverage percentage is a calculation of the number of covered lines divided by the sum of the number of covered lines and uncovered lines. Only executable lines of code are included.

The complete reference guide can be found in the Apex Developer Guide - Testing and Code Coverage

You must log in to answer this question.

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