Show TOC

Step 5: Displaying the Code Coverage ResultsLocate this document in the navigation structure

Procedure

Once you have created a measurement and collected code coverage data, you can view the coverage statistics in a graphical display. You fetch the display with CL_SCV_COVERAGE_UI=>GET_RESULT_DISPLAY, which takes a result object as its argument.

Sample Code

Here is sample code for displaying the result from the sample program in full-screen mode. Display in a dialog box is also possible.

DATA: display TYPE REF TO if_scv_result_display,
      result TYPE REF TO if_scv_result.

" Show code coverage in a graphical display
display = cl_scv_coverage_ui=>get_result_display( result ).
display->show_as_fullscreen( ).
"Or: display->show_as_popup( )"
            

If you need to, you can also save the results of your code coverage measurement. Go on to Step 6: Saving Code Coverage Results.

Here is the complete sample program.

Details

Results Hierarchy: By default, the Coverage API calculates coverages for all of the subcomponents of an entity that you specify. For example, IF_SCV_MEASUREMENT->BUILD_PACKAGE_RESULT returns by default the aggregate coverage for the package, as well as the results for all of the subpackages and programs in the package.

For this reason, the display generally shows a hierarchy of objects. The contents of the hierarchy are controlled by the configuration and selection that you specify.

If you calculated results for application components, then the top-level entities in the results are application components. If, on the other hand, you asked for results for programs, then the top-level elements in the display are programs.

In the coverage result tree, classes are shown under their class pool names, function groups are shown under their function pool names:

  • The display shows class CL_CCMS_AL_DATA_ENVIRONMENT as CL_CCMS_AL_DATA_ENVIRONMENT===CP.

  • The display shows function group SALI as SAPLSALI.

Source code display: If the display includes processing blocks, then you can click a processing block to display the branch and statement coverage in the source code. See The Details Display of the ABAP Coverage Analyzer for more information on the branch and statement display. The source code display is available only as long as the raw data is available.

Coverage Analyzer Display: Are you a QM and do you want to let your developers display the results of a measurement? Relax. You don't have to build your own display tool to do this. Instead, you can let your developers view measurement results in the Coverage Analyzer (transaction SCOV). Just give them the measurement test key and tell them to enter it as the Test group in the Details Display of the Coverage Analyzer. They can then view a measurement just as they could with the IF_SCV_RESULT_DISPLAY methods.