Setting code coverage acceptance levels

You can specify code coverage acceptance levels for one or more of the following elements: module, compilation unit, source file, or function. All criteria must be met in order for the program to be flagged as passing the code coverage requirements.

About this task

When you set code coverage levels, the level that you enter is the minimal acceptable percentage of code coverage. You can set acceptable code coverage levels for one or more of the following elements:
  • Module coverage
  • Compilation unit coverage
  • Source file coverage
  • Function coverage
By default, a code coverage launch uses a module threshold of 80% as its only acceptance criterion.
Attention: Before changing the threshold criteria for your code coverage launches, all pass and fail state information will be lost for previous launches generated prior to the current workbench session (i.e. if you shutdown the IDE and restart it, you must generate the report again before re-setting the threshold criteria if you want the new threshold status to be automatically applied to the previous launch). For more information, see Working with the Compiled Code Coverage Launch History view.

Procedure

To customize the code coverage acceptance levels or thresholds:
  1. Select Window > Preferences.
  2. Select Run/Debug > Compiled Debug > Code Coverage.
  3. Specify the minimum acceptable percentage of code coverage for one or more of the following elements:
    • Module coverage: the percentage of lines that must be covered in the module in order to meet the acceptance criteria.
    • Compilation unit coverage: the percentage of lines that must be covered in the compilation unit in order to meet the acceptance criteria.
    • Source file coverage: the percentage of lines that must be covered in the source file in order to meet the acceptance criteria.
    • Function coverage: the percentage of lines that must be covered in a function in order to meet the acceptance criteria.
    Use the check boxes, to select the desired elements. Enter the minimum acceptable code coverage percentages in the associated box for each element selected.

  4. Click the OK button.
  5. To restore the default acceptance criteria for a code coverage launch, open the code coverage preferences pages and click on the Restore Defaults button. The module threshold level will be reset to 80% and all other threshold levels will be deselected.

Note that all criteria must be met in order for the program to be flagged as passing the code coverage requirements. An icon will appear in the Compiled Code Coverage Launch History indicating whether the acceptance criteria passed or failed. Additionally, each failed element is decorated in the report view with a red "x" overlay. For example, using the preference set above (source file acceptance level of 44%) yielded the following code coverage report for the payroll program. Note the red "x" overlay next to payfunc.hpp because 19% code coverage is below the 44% acceptance criterion.


Feedback