Getting Code Coverage data

Code Coverage is based on the data that is gained from the most recent run of tests. Every test-run stores an entry, to the code coverage table, about each test class and method that was affected by it. The lines that were executed during these test-runs are also recorded.

NB: If you change the code between test-runs, to get the actual Code Coverage you need to build and run the updated tests, and then refresh Code Coverage.

The results of Code Coverage that you see in the Code Coverage panel are calculated during only test-runs. You also can run tests as a deployment validation but in this case, you won't see the Code Coverage results.

Aggregated Code Coverage Statistics

In cases, when you run a large amount of tests at the same time, the storing of code coverage may become slow. To avoid this issue, you can use the aggregated code coverage statistics. This option stores only the total number of lines covered for any given class, and this allows to reduce the potential number of code coverage records and to speed up the performance of test-runs.

NB: You can turn on this option on Salesforce: go to the Apex Test Execution page, click the Options… button and select Store Only Aggregated Code Coverage. Please notice, if you want to have the per-test coverage data, you will need to keep this option unselected.

In this section:

This also may be useful:

Last modified: 2017/02/02 15:33

footer image