Running code coverage for AIX® and Linux applications

Running code coverage provides insight into how well your test cases are exercising your compiled language applications by reporting results showing the percentage of lines in your code run by a test case as well as line by line coverage details.

About this task

You can run code coverage for any compiled language application that you can debug.

Procedure

  1. Compile your program with debug information.
    Note: If portions of the application do not have debug information, they are included in the report with this detail specified, but not included in any calculations (for example thresholds). Module level coverage always includes modules without debug information as part of its calculations.
  2. Run code coverage for your compiled language program either from the Toolbar, the Debug perspective or the Remote Systems Explorer perspective:
    • From the Toolbar or the Debug perspective:
    1. Using the Code Coverage pulldown on the toolbar Code Coverage pulldown, select Code Coverage Configurations....
      Tip: Alternatively, from the Debug perspective, select Run > Compiled Code Coverage Configurations....
    2. In the Program tab of the Compiled Code Coverage Configurations dialog, choose the RSE connection and specify the program that you want to run code coverage against.
    3. Optional: Set code coverage parameters. By default, code coverage results are collected independently for each run. However, you may want to collect code coverage data on the same program under different parameters or using different scenarios. For example, using different parameters may affect the execution of lines within an if or else block. In these cases, you have the option of collecting code coverage results cumulatively as this will improve code coverage performance. To choose this option:
      • Select the Code Coverage tab.
      • Select one of Run full coverage (default), or Append to the previous result (which will use the results from the previous result as the baseline for the current launch), or Append to a specific result (which will use the code coverage results from the result file you specify as the baseline for the current launch).
      • Specify the Code Coverage Level. By default, code coverage is run at the line level. However for performance reasons, you may want to run code coverage at the function, or module level. Optional: When running module level code coverage, specify a module file which contains the list of expected modules.
      • Specify the Report Options. By default, a workbench report is always produced. Select Generate HTML report to have an HTML report produced after the code coverage run is complete. Select Generate PDF report to have a PDF report produced after the code coverage run is complete.
      • Specify the Additional Options. Select Ignore errors to force code coverage to produce a report, regardless of error conditions. Specify desired Tags to be associated with the code coverage run. For example, you may wish to tag a code coverage result with a test case name or number.
      • Click Apply.
    4. Click the Coverage button.
    • From the Remote Systems Explorer perspective:
    1. Select the compiled program.
    2. Right-click and select Compiled Code Coverage > Compiled Application.

Results

Code coverage data collection is launched in the Debug perspective but the code coverage report automatically opens in the perspective that is current after the data collection is complete. Now you can view the code coverage results.

Feedback