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.
- Create a code coverage configuration for a batch program. Right-click the program and select
A compiled
code coverage configuration is created and opened in the
Edit
configuration and launch dialog.
Note: An alternative method
to launch code coverage is right-click your program and select . In this case, a configuration is created and the code
coverage session is started without opening the Edit configuration
and launch dialog. If your program is simple and does
not require any additional set up such as adding called programs,
this can be a convenient method for starting code coverage.
- Add any programs or service programs that are called by
your main program. Under the What To Analyze tab,
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 How To Start, you can change the command
used to start the application. 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 the Coverage button to start
the code coverage session.
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.
When the program
completes, a workbench report is opened and an item summarizing the
coverage is added to the Compiled Code Coverage Results view.