Show TOC

Setting Thresholds for Code CoverageLocate this document in the navigation structure

Procedure

You can specify the thresholds for code coverage that the Coverage Analyzer will use.

The Coverage Analyzer sets the traffic light icons in the Status field in the Detail Display and Global Display according to these thresholds: red if the code coverage is too low, yellow or green for code coverages higher than the "red" threshold.

Note

The fields in Current procedure coverage: Condition for 'Processing block tested' also help determine the Status icon. By default, Status is red if a processing block has not been executed, if a short dump occurred during processing, and so on. It is usually best to leave these fields unchanged.

Setting Thresholds

Here is a suggested best practice for setting code coverage thresholds:

  1. Decide which of the three code coverage measures is the most important for you: procedure coverage, branch coverage, or statement coverage.

    There is a considerable literature on code coverage, but here are some basic guidelines:

    • If you are testing legacy code - not designed for modern testing - then procedure coverage may be the most useful code coverage measure for you.

      If you don't have a lot of control over the execution paths taken in the code under test, then it makes sense to use the least exact measure of code coverage, which is procedure coverage. Trying to use branch coverage or statement coverage as your measure of code coverage is futile if you cannot force the code in your tests to follow different execution paths.

      Aiming for a high coverage of the important procedures (classes, methods, function modules, form routines) in the code under test makes it likely that your tests cover the most important use cases of the code.

    • If your development is optimized for testing, then you will want to use branch or statement coverage as your measure of code coverage.

      If you can easily control execution paths in tests, then you can use more precise measures of code coverage, and aim for a high branch coverage or statement coverage. With these measures, the Coverage Analyzer supports modern programming techniques.

  2. Set the code coverage thresholds.

    In transaction SCOV, the Coverage Analyzer, choose Start of the navigation path Coverage Analyzer Next navigation step Administration Next navigation step Settings End of the navigation path.

    Set the traffic light thresholds for code coverage in the Light Settings: Coverage Evaluation frame.

    Specify threshold values that suit the most important code coverage measure, which you selected in step 1.

    For example, if you chose procedure coverage as the most important measure, then set traffic light values according to the procedure coverage you want to reach.

    Note that the thresholds apply to all three of the code coverage measures. You cannot set individual thresholds for each measure.

  3. In the Detail Display and Global Display, create layout variants for evaluating code coverage.

Background Information: How the Thresholds Work

The settings that control the Status"traffic light" icon in the Detail Display and the General Procedure Coverage icon in the Global Display are a little bit complicated. This section explains how the settings work.

The Status"traffic light" columns in the displays are important because they give you an instant indication as to whether the code coverage for a package or program is adequate or not.

The "traffic light" columns are controlled by the settings that you make. The settings work as follows:

  • On the Settings screen, the fields in the Light Settings: Coverage Evaluation frame set the thresholds for code coverage.

    The thresholds for red, yellow, and green that you set here apply equally to the Current Procedure Coverage (Percent), Current Statement Coverage (Percent), and Current Branch Coverage (Percent) fields in the displays.

    The thresholds that you want to set for different code coverage measures may, of course, not be the same. Since different thresholds are not supported, you must decide which measure is most important. You can then base your code coverage evaluations on this measure.

  • On the Settings screen, the fields in the frame Current procedure coverage: Condition for "Processing block tested" let you add special tests to the traffic light determination.

    By default, these special tests require that a processing block has run at least once and that no short dumps occur during testing.

    These special tests work by overriding the values in the Current Procedure Coverage (Percent) column.

    For example, if a short dump occurs, then the Coverage Analyzer overrides the Current Procedure Coverage value and sets it to 0. With respect to this value, the Status traffic light icon for the program in the Detail Display will be set to red. In the Global Display, the program will contribute 0% procedure coverage to the aggregated package procedure coverage.

    If you change these settings, then you should always include the Current Procedure Coverage (Percent) column in your display variants. You should also be aware that a 0% value in this column may mean that a special threshold condition has been violated.