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

How to keep code coverage information accurate for as much of the time as possible?

I want to have accurate code coverage statistics continually, without degrading deployment times (all my deployments are via ANT, not change set). Based on some reading (see links below) I believe that:


- The most accurate code coverage is via manual apex test execution via GUI - but only if previous values are cleared out first

- Eclipse & Developer Console can't be trusted to accurately calculate and update the coverage statistics

- Deployments with runAllTests=true also accurately calculate the coverage statistics - but don't update them

- "Store Only Aggregated Code Coverage" is suggested to run tests faster - but this has no impact on deployment times because of the previous point


And based on this I believe the following is the best I can do:


- After every major deployment (including those with runAllTests=true), clear the code coverage, clear test history and manually run all tests.

- Don't bother setting Store Only Aggregated Code Coverage for deployments with runAllTests=true as this will make no difference to deployment time.


Is my thinking correct?


Reference info:

Bhawani SharmaBhawani Sharma
Please have a look of this. It will make your life easy:

Thanks for the reply.


It looks like this code uses the Apex Test Runner? According to one of the posts I referenced, this is not considered reliable?


Also am I correct in thinking that coverage isn't updated in the org itself by this code and is only available in an emailed spreadsheet?