Contents
How do you explain code coverage?
Code coverage is a measure which describes the degree of which the source code of the program has been tested. It is one form of white box testing which finds the areas of the program not exercised by a set of test cases.
How do I view code coverage in Salesforce?
Follow these steps every time you run the code coverage to have reliable coverage details:
- Navigate to Setup.
- In the Quick Find Search type ‘Apex’ and select ‘Apex Test Execution’
- Click Options.
- Deslect ‘Store Only Aggregated Code Coverage’ and click ‘OK’
- Click ‘View test history’
- Click ‘Clear all test history’
How is code coverage calculated in Salesforce apex?
You may have noticed the numerator/denominator lines in the Apex Classes list page, which show how many lines are covered based on how many lines could be covered. These values are calculated based on the code coverage table, too. The code coverage data is stored when your tests finish running.
What does it mean to have code coverage?
Code coverage serves as one indication of test effectiveness, but doesn’t guarantee test effectiveness. The quality of the tests also matters, but you can use code coverage as a tool to assess whether you need to add more tests.
How to check code coverage in apex developer guide?
The tests for this class have been run, and the option to show code coverage was chosen for this class in the Developer Console. The blue lines represent the lines that are covered by tests. The lines that aren’t highlighted are left out of the code coverage calculation. The red lines show the lines that weren’t covered by tests.
When does a code coverage record get deleted?
Each record is valid until either the class with the test or the class being covered are modified. If either parent class is altered, the code coverage record is deleted, removing the knowledge of the last run of that test.