Text Output

The text output format summarizes coverage in a plain-text table. This is the default output format if no other format is selected. This output format can also be explicitly selected with the gcovr --txt option.

Added in version 5.0: Added explicit --txt option.

Example output:

------------------------------------------------------------------------------
                           GCC Code Coverage Report
Directory: .
------------------------------------------------------------------------------
File                                       Lines    Exec  Cover   Missing
------------------------------------------------------------------------------
example.cpp                                    7       6    85%   7
------------------------------------------------------------------------------
TOTAL                                          7       6    85%
------------------------------------------------------------------------------

Line Coverage

Running gcovr without any explicit output formats …

gcovr

generates a text summary of the lines executed:

------------------------------------------------------------------------------
                           GCC Code Coverage Report
Directory: .
------------------------------------------------------------------------------
File                                       Lines    Exec  Cover   Missing
------------------------------------------------------------------------------
example.cpp                                    7       6    85%   7
------------------------------------------------------------------------------
TOTAL                                          7       6    85%
------------------------------------------------------------------------------

The same result can be achieved when explicit --txt option is set. For example:

gcovr --txt

generates the same text summary.

Each line of this output includes a summary for a given source file, including the number of lines instrumented, the number of lines executed, the percentage of lines executed, and a summary of the line numbers that were not executed. To improve clarity, gcovr uses an aggressive approach to grouping uncovered lines and will combine uncovered lines separated by “non-code” lines (blank, freestanding braces, and single-line comments) into a single region. As a result, the number of lines listed in the “Missing” list may be greater than the difference of the “Lines” and “Exec” columns.

Note that gcov accumulates statistics by line. Consequently, it works best with a programming style that places only one statement on each line.

Branch Coverage

The gcovr command can also summarize branch coverage using the -b/--branches option:

gcovr --branches

This generates a tabular output that summarizes the number of branches, the number of branches taken and the branches that were not completely covered:

------------------------------------------------------------------------------
                           GCC Code Coverage Report
Directory: .
------------------------------------------------------------------------------
File                                    Branches   Taken  Cover   Missing
------------------------------------------------------------------------------
example.cpp                                    2       1    50%   5
------------------------------------------------------------------------------
TOTAL                                          2       1    50%
------------------------------------------------------------------------------

The same result can be achieved when explicit --txt option is set. For example:

gcovr --branches --txt

prints the same tabular output.