Given two classes with test classes:
- 400 testable lines: 200 covered
- 10 testable lines, 10 covered
How will the test coverage be calculated? Average of the coverage for each class, or the ratio of all tested lines together to the total amount of code in the org?
First method: class one has 200/400 = 50% coverage, class two has 10/10 = 100% coverage. Average is (50% + 100%)/2 = 75%, which meets the minimum requirements for production deployment.
Second method: 200 + 10 = 210 covered lines, 400 + 10 = 410 total lines. Coverage is 210/410 = 51.2%, which is too low.
I did read How is Total code Coverage on ApexClass calculated as well as the linked blog post How Code Coverage Works, but neither seem to address this specific question. That is, I have not seen an example like the one in this question.
My current task is to pick up the slack left behind by an overly-aggressive development schedule. I need to know if it is worth squeezing an extra line of coverage from a small class, or extend the same effort to cover ten lines in a large class (I assume larger classes have more opportunities to cover odd sections of code, which has proven true on this project so far).