CodeCoverage » History » Revision 2
Revision 2/8
| Next »
Yi Huang, 02/18/2014 02:46 PM
Code Coverage¶
This guide has instructions to generate code coverage report on your local machine in HTML or plain text.
Install required command-line tool (gcovr) and configure the project to generate temporary profiling files:¶
Install
gcovr
on your machine. sudo easy_install gcovrWhen configuring, add option "--with-coverage" (e.g.
./waf configure --with-tests --with-coverage
). If the build or running unit tests requires other packages, all the packages should be configured with the option "--with-coverage". For example,ndn-cpp-dev
requiresndnd-tlv
to run its unit tests, then when configuringndn-cpp-dev
, we should use "./waf configure --with-tests --with-coverage
", and when configuringndnd-tlv
, we should use "./waf configure --with-coverage
".
To create code coverage report (HTML format) follow the steps below:¶
After building the project and running unit tests, use
gcovr
to generate detailed code coverage report in html form. The following is a one-liner:
mkdir build/coverage; gcovr -r . --object-directory=build/ --html --html-details -o build/coverage/coverage.htmlUse any browser to open
build/coverage/coverage.html
to see the code coverage report.
To create code coverage report (PLAIN TEXT) follow the steps below:¶
After building the project and running unit tests, use
gcovr
to generate detailed code coverage report in plain text. The command is:
gcovr -r . --object-directory=build/ --html-details -o build/coverage.txtUse any plain text editor/reader to open
build/coverage.txt
to see the code coverage report.
Updated by Yi Huang almost 11 years ago · 7 revisions