You need to sign in to do that
Don't have an account?
jkang
Code Coverage Calculations
Can someone please help me understand how code coverage is calculated? This is what I currently have. As you can see, individually all my classes and triggers are at 100%, but somehow my overall coverage is only 79%. This doesn't make sense to me. It's not a big deal except that I don't want to get into a situation where it won't let me deploy because it calculates my coverage as being below 75%.
Not sure but when you write a test method inside an apex class to cover the same class code then that code is also counted in the overall code coverage. So make sure you have all test classes written in new apex class and not within the test class. And all classes have @Test annotation.
Well, I tried that and succeeded in REDUCING my code coverage to 61%. And yes, all my test classes are annotated with @isTest.
I've seen percentages be off by a point or two, but I've never seen it this far off the mark. Has anyone else experienced this?
FYI - this is of no value, but yes, I've found the test coverage calculation to be seemingly random.
I've noticed the following factored into the calculations:
1) Order/placement of code being tested (e.g. I had methods A and B and got one calculated value, then switched B to preced A and the calculation changed).
2) The value shown in the IDE changes after running the tests from the browser.