1

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

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.

  • 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 '18 at 4:44
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.