+ Start a Discussion
JThomasJThomas 

Calculated Code Coverage does not match the Code Coverage after Run All Tests

I've noticed in our production environment that when I go to the Calculate Code Coverage for Your Organization link in the Setup->Develop->Apex Classes menu that the calculated code coverage is quite different than the total code coverage after clicking on Run All Tests.  Does anyone know which is correct?  Also, when I click on one of the percentages to see the code coverage of a given file, it seems to always say that the file was modified since the last test run.  How can that be when all tests are ran any time a change is made to production?  I'm guessing that the Run All Tests code coverage is correct, but why isn't that data being saved off and pulled when Calculate Code Coverage is clicked?

Best Answer chosen by Admin (Salesforce Developers) 
Shashikant SharmaShashikant Sharma

Calculate your organization's code coverage to find out how much of the Apex code in your organization is currently covered by unit tests. This percentage is based on the latest test results. If you have no test results, code coverage is listed at 100%. For more information

 

If you have unit tests in at least one Apex class, click Run All Tests to run all the unit tests in your organization.

 

The code coverage value computed by Calculate your organization's code coverage may differ from the code coverage value computed after running all unit tests using Run All Tests. This is becauseCalculate your organization's code coverage excludes classes that are part of installed managed packages while Run All Tests doesn't.

 

To See More Go To : https://login.salesforce.com/help/doc/en/code_manage_packages.htm

All Answers

Shashikant SharmaShashikant Sharma

Calculate your organization's code coverage to find out how much of the Apex code in your organization is currently covered by unit tests. This percentage is based on the latest test results. If you have no test results, code coverage is listed at 100%. For more information

 

If you have unit tests in at least one Apex class, click Run All Tests to run all the unit tests in your organization.

 

The code coverage value computed by Calculate your organization's code coverage may differ from the code coverage value computed after running all unit tests using Run All Tests. This is becauseCalculate your organization's code coverage excludes classes that are part of installed managed packages while Run All Tests doesn't.

 

To See More Go To : https://login.salesforce.com/help/doc/en/code_manage_packages.htm

This was selected as the best answer
DontFeedTheMikeyDontFeedTheMikey

This doesn't answer what I'm seeing. I'm in a base package, no installed package in my base or namespace. I ran test and get one code coverage % and then turn around and run Calculated Code Coverage and get another. All test pass. Another funny thing is when viewing the code coverage to a class. I see where in an If statement the closing bracket is not cover "}" but the code inside the if statement is. Do you know what is happen here?

Tomas.Ray2012Tomas.Ray2012
Apex trigger also counts