function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VernonBaasVernonBaas 

Recalculate Code Coverage

I have been working on updating test classes improving my code coverage.  How can I force Salesforce to update its data on my code coverage?

 

After running the updated test classes and running all of the tests from the Force.com IDE I am told '0 lines not tested, 100% covered'.  But from my Sandbox instance the percentage of code coverage fails to update.  I've run the individual test class within Salesforce in addition to running all of my tests from the 'Apex Test Execution' section of my instance but the percentage of coverage and the data regarding the lines of source code that are covered does not get updated.  

 

I know I've improved my test coverage but when I click on the XX%(XX/XX) link I'm shown the new code but with the old pattern of red and blue lines representing the outdated pattern of covered/not-covered bars.  Lines that are now commented out have red/blue bars in the same locations before I updated the code.

 

Best Answer chosen by Admin (Salesforce Developers) 
TheDoctorTheDoctor

On the APEX Classes page, try clicking on the 'Clear Code Coverage' button. Once this has done, click on the 'Run All Tests' button. Should do the trick.

All Answers

TheDoctorTheDoctor

On the APEX Classes page, try clicking on the 'Clear Code Coverage' button. Once this has done, click on the 'Run All Tests' button. Should do the trick.

This was selected as the best answer
VernonBaasVernonBaas

Thanks for identifying the 'Clear Code Coverage' button, I'd overlooked that.  

 

Pressing it clears out my code coverage but after pressing the 'Run All Tests' button, the Code Coverage column remains blank.  Looking at any specific class/trigger shows '0% (No Coverage Data)'.

 

Clicking on the 0% link displays the Code Coverage screen with the updated test data and the message 'Code Coverage 100%'.  After viewing that page, the code coverage displays for that class on the Trigger Specific page as well as the list of triggers.  I guess I'll have to go into each of my classes and view the coverage if I want the updated coverage results to propagate.

 

Thanks!

TheDoctorTheDoctor

This doesn't sound right. You may want to raise this with the Tech Support team.