Skip to content

Command Line Interface

Cover++ has multiple subcommands.

Run a program under coverage.

Terminal window
cover++ run [options] <program> [args...]
OptionDescription
<program>The executable to run under coverage.
<args...>Arguments passed verbatim to the program.
-s
--source <path>
Filter the files for which coverage is collected to this directory.
Default: Computed as the root directory of the <program>. For example, running cover++ run D:\foo\bar\baz.exe will use D:\foo as the source root.
-d
--debug-info <path>
Path to the PDB file.
Default: Same as the program, with .exe replaced by .pdb
-o
--out <path>
Where to generate the coverage report.
Default: ./report.coverpp
--exclude-source-files-regex <regex>Source files matching this regex are excluded from coverage. The paths are canonical and use forward slashes.
Default: /(vcpkg_installed|_deps)/
-v
--verbose
Repeatable flag to increase verbosity.
--print-first-chance-sehPrint first-chance SEH exceptions to the console

All arguments passed after <program> are forwarded verbatim to the program.

View a coverage report in the browser.

Alias: serve

Terminal window
cover++ view [options] [report]
OptionDescription
<report>Report file to view.
Default: ./report.coverpp
-p
--port <port>
Port to serve the report on.
Default: 8080
--coverpp-install-dirInstallation directory of Cover++.
Default: Auto-discovered.
--no-openDon’t open the browser; only start the server.

Remap source locations in a coverage report file.

Terminal window
cover++ remap [options] --to <path> [report]
OptionDescription
<report>Report file to modify.
Default: ./report.coverpp
--to <path>New source root.
Required.
--from <path>Old source root.
Default: Inferred from the single source root in the report.

Note that --from is required if there is more than one source root.

You can remap subdirectories of a source root. In that case, the original root will be split in two.

It is not required that either the old or the new source root exist. If the new source root does exist, missing statistics which require source files will be computed. This is useful in case the report was generated on a machine without the source files.

Merge multiple coverage reports into a single file.

Terminal window
cover++ merge -o <output> <inputs...>
OptionDescription
-o
--out <path>
Where to place the merged report.
<inputs...>One or more report files.

Export a coverage report to a JSON file.

Terminal window
cover++ export json [-o <output>] [report]
OptionDescription
-o
--out <path>
Where to place the generated JSON file.
Use - to print to the console.
Default: -
<report>The report file to export.
Default: ./report.coverpp

Export foo.coverpp to foo.json:

Terminal window
cover++ export json -o foo.json foo.coverpp

Get the covered lines of a specific file in the first root:

Terminal window
$report = cover++ export json foo.coverpp | ConvertFrom-Json
$report.roots[0].children | where file -eq "main.cpp" | select covered

Export a coverage report to gcov format.

Alias: export clion

Terminal window
cover++ export gcov [-o <output>] [report]
OptionDescription
-o
--out <path>
The directory in which to place the generated gcov files..
Default: coverage-gcov-export
<report>The report file to export.
Default: ./report.coverpp

Gcov’s format is useful primarily because other tools support it. Cover++ supports exporting reports in a format compatible with gcov to enable integration with such tools.

One .gcov file per source file is created in the output directory. They are named according to a flat numbering scheme (001.gcov, 002.gcov, …). Each generated file contains the path to the source file and associated coverage information per line.

Starting with CLion 2026.2, it’s possible to import gcov files into the IDE1. To do so, open the Coverage tool window and click Import a report collected in CI from disk. Then, select ALL files in the exported directory.

Export a coverage report as TeamCity statistics.

Terminal window
cover++ export teamcity-statistics [report]
OptionDescription
<report>The report file to export.
Default: ./report.coverpp

This exporter prints TeamCity service messages that, when running under TeamCity, attach coverage statistics to the build.

There are two primary use cases for this:

  • Quality gates: TeamCity can be configured to fail the build if coverage drops under a certain threshold. This can then be used, for example, to block pull requests.

  • Charts: You can create charts in TeamCity showing how coverage has evolved over time.

  1. See CPP-48737