Thursday, 13 September 2018

Eliminate bad code coverage data for Apex classes:


Issue: There may be times where we see a different code coverage value than the actual value. This might be caused due to bad code coverage data or aggregate results from previous test runs.

Solution: To eliminate any bad code coverage data in your organization you can follow the steps mentioned below.

For Classic:
---------------------------------------------------------------------------------
First re-run all tests in your organization: 
---------------------------------------------------------------------------------
1a) Setup | Develop | Apex Test Execution
  b) View Test History
  c) Clear test data.

2 a) Setup | Develop | Apex Classes
  b) Compile all classes

3 a) Setup | Develop | Apex Test Execution
 b) Select tests | "My Namespace" | Select all
 c) Click run

4 a) Setup | Develop | Apex Classes
  b) Estimate your organization's code coverage

  ---------------------------------------------------------------------------------
To Remove Bad data:
---------------------------------------------------------------------------------
1 a) Open Developer console
  b) Execute the following query in "Query Editor" with "Tooling API" checked.

SELECT Id, NumLinesUncovered FROM ApexCodeCoverageAggregate WHERE NumLinesUncovered = NULL

c) Select all the returned rows and hit "Delete Row"
d) Try to estimate the code coverage again
---------------------------------------------------------------------------------

No comments:

Post a Comment