BullseyeCoverage
Use covhtml to generate HTML pages that you can navigate and sort similarly to the Coverage Browser.
You can generate textual reports by directory, source file, C++ class/namespace, or function using the covdir, covsrc, covclass, or covfn command, respectively. By default, the reports are sorted first by the percentage of functions invoked, and then by the percentage of decisions and conditions covered.
Directory Function Coverage C/D Coverage --------- --------------------- --------------------- calc/ 10 / 10 = 100% 21 / 50 = 42% expr/ 19 / 19 = 100% 87 / 111 = 78% --------- --------------------- --------------------- Total 29 / 29 = 100% 108 / 161 = 67%
Source Function Coverage C/D Coverage ------------------- --------------------- --------------------- calc/Calculator.cpp 2 / 2 = 100% 10 / 33 = 30% expr/main.cpp 1 / 1 = 100% 2 / 6 = 33% calc/CalcCore.cpp 7 / 7 = 100% 11 / 17 = 64% expr/Parser.cpp 14 / 14 = 100% 40 / 58 = 68% expr/Lexer.cpp 3 / 3 = 100% 45 / 47 = 95% calc/CalcCore.h 1 / 1 = 100% 0 / 0 expr/Lexer.h 1 / 1 = 100% 0 / 0 ------------------- --------------------- --------------------- Total 29 / 29 = 100% 108 / 161 = 67%
Class Function Coverage C/D Coverage ---------- --------------------- --------------------- CalcCore:: 8 / 8 = 100% 11 / 17 = 64% Parser:: 14 / 14 = 100% 40 / 58 = 68% Lexer:: 4 / 4 = 100% 45 / 47 = 95% ---------- --------------------- --------------------- Total 26 / 26 = 100% 96 / 122 = 78%
Function Source Line Function Coverage C/D Coverage ----------------------------------- --------------------- --------------------- --------------------- Parser::logical_and_expression() expr/Parser.cpp 194 1 / 1 = 100% 1 / 6 = 16% main(int,char*[]) expr/main.cpp 8 1 / 1 = 100% 2 / 6 = 33% Parser::logical_or_expression() expr/Parser.cpp 204 1 / 1 = 100% 3 / 6 = 50% Parser::equality_expression() expr/Parser.cpp 147 1 / 1 = 100% 2 / 4 = 50% Lexer::unitTest() expr/Lexer.cpp 9 1 / 1 = 100% 1 / 2 = 50% Parser::unitTest() expr/Parser.cpp 5 1 / 1 = 100% 1 / 2 = 50% Parser::and_expression() expr/Parser.cpp 164 1 / 1 = 100% 1 / 2 = 50% Parser::exclusive_or_expression() expr/Parser.cpp 174 1 / 1 = 100% 1 / 2 = 50% Parser::inclusive_or_expression() expr/Parser.cpp 184 1 / 1 = 100% 1 / 2 = 50% Parser::expression() expr/Parser.cpp 214 1 / 1 = 100% 1 / 2 = 50% Parser::primary_expression() expr/Parser.cpp 35 1 / 1 = 100% 4 / 6 = 66% Parser::multiplicative_expression() expr/Parser.cpp 62 1 / 1 = 100% 9 / 10 = 90% Lexer::read(Token&) expr/Lexer.cpp 45 1 / 1 = 100% 44 / 45 = 97% Lexer::unitTest(const char*) expr/Lexer.cpp 38 1 / 1 = 100% 0 / 0 Lexer::Lexer(const char*) expr/Lexer.h 41 1 / 1 = 100% 0 / 0 Parser::Parser(const char*) expr/Parser.cpp 30 1 / 1 = 100% 0 / 0 Parser::additive_expression() expr/Parser.cpp 90 1 / 1 = 100% 4 / 4 = 100% Parser::shift_expression() expr/Parser.cpp 107 1 / 1 = 100% 4 / 4 = 100% Parser::relational_expression() expr/Parser.cpp 124 1 / 1 = 100% 8 / 8 = 100% ----------------------------------- --------------------- --------------------- --------------------- Total 19 / 19 = 100% 87 / 111 = 78%
Use
covbr
to see details about which specific control structure conditions were not covered.
By default, covbr
displays coverage for the entire project.
Since this is usually a large amount of information,
you may wish to pipe the output through more
.
covbr | more
The detail report is an annotated listing of the source file.
In the left margin, arrows -->
indicate incomplete
coverage and the letters X
, T
, F
,
t
, and f
indicate coverage which has
occurred. Uninteresting sections are replaced by "...
".
For example, the command covbr calc2.c:main
produces the following.
expr/main.cpp: ... 5 #include "Lexer.h" 6 #include "Parser.h" 7 X 8 int main(int argc, char *argv[]) 9 { 10 try { 11 Lexer::unitTest(); 12 Parser::unitTest(); 13 std::string line; -->F 14 if (argc > 1) { --> 15 for (int i = 1; i < argc; i++) { 16 line += argv[i]; 17 line += " "; 18 } ... 22 } 23 Parser parser(line.c_str()); 24 std::cout << parser.expression() << std::endl; X 25 } --> 26 catch (const char *s) { 27 std::cerr << s; 28 } 29 return 0; ...
This shows the function main
was invoked, the condition
!feof(stdin)
on line 269 evaluated to both true and
false, the decision on line 272 evaluated only to false, the decision
tested on line 273 was never encountered, and the decision on
line 276 evaluated only to true.
By default, BullseyeCoverage shows coverage for the entire project. You
can reduce the amount of output by specifying regions.
For example, the command
covfn expr/Lexer.cpp
shows only the functions in that source.
Function Source Line FnCov C/D Coverage ---------------------------- -------------------- ----- --------------------- Lexer::unitTest() expr/Lexer.cpp 9 1 / 1 1 / 2 = 50% Lexer::read(Token&) expr/Lexer.cpp 45 1 / 1 44 / 45 = 97% Lexer::unitTest(const char*) expr/Lexer.cpp 38 1 / 1 0 / 0 ---------------------------- -------------------- ----- --------------------- Total 100% 45 / 47 = 95%
Sometimes after building a large project, you discover functions,
classes, or source files which you do not want BullseyeCoverage to report.
With the command line programs you can exclude regions from reports
by specifying those regions prefixed with !
.
All the BullseyeCoverage commands automatically process an argument
file with the same name as the command, but with suffix
.cfg
.
BullseyeCoverage reads options from each of the locations below, in order.
/bin
USERPROFILE
environment variable on Windows,
HOME
on Unix-like systems.
The example commands below show how you could create an argument file for covdir to use verbose mode.
echo -v >%USERPROFILE%\covdir.cfg ← Windows echo -v >$HOME/covdir.cfg ← Unix-like shell
Updated: 31 Aug 2023
Copyright © Bullseye Testing Technology. All Rights Reserved.