Running code coverage provides insight into how well your
test cases are exercising your IBM i 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. You can run code coverage for
any IBM i application that you can debug.
Procedure
- Compile your program with the source debug option.
Note: - You need to use one of the DBGVIEW(*ALL) or DBGVIEW(*SOURCE) options.
Code coverage does not support programs compiled with the DBGVIEW(*LIST) option.
- If portions of the application do not have debug information,
only those portions of the application with debug information are
included in the code coverage report.
- Run code coverage for your IBM i program either from the Toolbar,
the Debug perspective or the Remote Systems Explorer perspective:
- From the Toolbar or the Debug perspective:
- Using the Code Coverage pulldown on the toolbar
,
select Compiled Code Coverage Configurations.... Tip: Alternatively, from the Debug perspective, select .
- Create a new configuration. Right-click IBM
I: Code Coverage Batch Application and click New.
- In the What to Analyze tab of
the Compiled Code Coverage Configurations dialog,
choose the RSE connection and add the programs and service programs
that you want to run code coverage against.
- In the How to Start tab, you
can modify the command to start the code coverage job. You can set
program parameters and job control parameters from this tab.
Note: The
parameter INQMSGRPY(*DFT) is set for a code coverage
run by default.
- 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 either Append to the previous result (which
will use the results from the previous launch as the baseline for
the current launch) or Append to a specific result (which will
use the code coverage results from the launch 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 procedure, or program level. Optional:
When running program level code coverage, specify a program file
which contains the list of expected programs.
- Optional: 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.
- Optional: 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.
- Click the Coverage button.
- From the Remote Systems Explorer perspective:
- Select the IBM i program.
- Right-click and select or . The first action will launch a code coverage
session immediately without prompting for launch parameters. The second
action will open the Compiled Code Coverage launch
configurations dialog box and allow you to modify the launch parameters.
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.