To run code coverage in headless mode using the code coverage collector, start
the collector and run the application with settings specified to connect to the code coverage
daemon. The daemon listens on one or more ports, waiting for incoming code coverage
sessions.
Before you begin
Notes:
- The headless code coverage collector is not available on macOS.
- By default, results are stored in the home directory of the user that started the headless code
coverage collector in a directory called CC. This location can be overridden by
using the
-o,output
parameter. For a syntax diagram and a complete list of options,
see Starting and stopping the headless code coverage collector.
Procedure
- Start the headless code coverage collector. The code coverage daemon starts
and assigns a port number. The daemon then echoes the port on the console via message CRRDG7026,
echoes the process ID of the code coverage headless collector via message CRRD7027, and waits for a
connection.
> codecov -startdaemon
Note:
- You can specify a port number or a range of port numbers with
-p,port
:
codecov -startdaemon -port=8009
or codecov -d -p=8009-8109
.
- If you are running headless code coverage on Windows or Linux, the executables are in the
headless-cc subdirectory where you installed the product.
- If you are running headless code coverage on z/OS®, use
the
ccstart.sh
script in
/usr/lpp/IBM/debug/headless-code-coverage/bin/ directly to start a code
coverage daemon.
- You can start multiple daemons each having different options, so long as unique port numbers are
used.
- Configure for code coverage with either a debug profile or the
TEST
runtime option:
- Start the application. When code coverage is completed, a message is displayed to indicate the
results of the code coverage run.
- To stop the code coverage daemon, specify
> codecov
-stopdaemon=<port>
. For example, to stop the code coverage daemon running on port 8009,
specify > codecov -D=<port>
. If you are using headless code coverage on z/OS, you can use the ccstop.sh
script in
/usr/lpp/IBM/debug/headless-code-coverage/bin/.
Note: You can also stop the code coverage daemon by pressing ctrl-c
or
ctrl-break
on the command line. Stopping the daemon with this method skips the
cleanup function and might result in working directories in the output directory. The working
directories that appear as folders with long numbers as the names can be safely deleted when no code
coverage daemon is running.