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), DBGVIEW(*SOURCE),
or DBGVIEW(*LIST) options.
- Compiler optimization can affect the report of lines covered.
For the most accurate results, compile with OPTIMIZE(*NONE).
- 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.
- Browse to your program under your connection
in Remote Systems Explorer. If you want, you can create
filters or add library list entries to facilitate finding your programs.
- Set a service entry point. A service entry point
is added to the IBM i Service Entry Points view.
- Set the service entry point to code coverage mode. Right-click the service entry point and select Code
Coverage Mode. Alternatively, select the Code Coverage
toolbar button in the view
. Note that the default mode for
service entry points is debug mode. If you restart the IDE, the mode
will be reset to debug mode.
- Optional: Edit the configuration if you want
to modify the default code coverage parameters.
- Open the launch configuration. Right-click
the service entry point and select Open Launch Configuration.
The edit configuration dialog opens.
- Add any programs or service programs that are called
by your main program. Click the Add button
to add additional called programs. Called programs after
they are added. The main program is selected.
- Edit the configuration as necessary. For
example, under What to Analyze, you can specify
the debug view used for analysis. Under Code Coverage,
you can specify details such as whether coverage is on the Line or
Procedure level. For more information about configurations, see Editing code coverage configurations.
- Click Apply and Close to
save the configuration and return to the IBM i Service
Entry Points view.
- In a 5250 terminal, call your main program. The
service entry point configuration that you created will listen for
the program to start.
The status bar at the bottom of the
IDE displays the message Running code coverage for PROGRAM_NAME.
Where PROGRAM_NAME is the name of your program.
If
the program is interactive, it opens in the 5250 terminal and is ready
for running tests.
- For interactive programs, use the program according to
your test procedures, then exit the program
- For batch programs, wait until the program is finished
running. After the program is exited, a workbench report
is opened and an item summarizing the coverage is added to the Code
Coverage Results view.