Generating code coverage in headless mode using a daemon

To run code coverage in headless mode using a daemon, start the code coverage daemon and run the application with settings specified to connect to the code coverage daemon.

Before you begin

Notes:
  • The code coverage headless collector is not available on macOS.
  • By default, results are stored in the home directory of the user that started the code coverage headless collector under a directory called CC. This location can be overridden by using the output parameter. For a syntax diagram and a complete list of options, see Starting and stopping the headless code coverage daemon.

Procedure

  1. Start a code coverage daemon. The daemon assigns a port number and echoes it on the console via message CRRDG7026, echoes the process ID of the code coverage headless collector via message CRRD7027, and then waits for a connection.
    > codecov -startdaemon
    Starting code coverage in daemon mode
    Note:
    • You can specify a specific port by adding -p/port=<port list> and the port number or range of port numbers: codecov -startdaemon -port=8009 or codecov -d -p=8009.
    • 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. Standard mode is not supported with headless code coverage on z/OS.
    • You can start multiple daemons each having different options, so long as unique port numbers are used.
  2. Configure for code coverage with either a debug profile or the TEST runtime option:
  3. Start the application. When code coverage is completed, a message is displayed to indicate the results of the code coverage run.
    Output results of code coverage run
  4. 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/.
    Output results of code coverage run
    Output results of code coverage run
    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.