Project

General

Profile

CodeCoverage » History » Version 7

Davide Pesavento, 10/11/2016 03:35 AM
Fix formatting; delete obsolete example

1 2
Code Coverage
2
============
3
4
This guide has instructions to generate code coverage report on your local machine in HTML or plain text.
5
6
## Install required command-line tool (gcovr) and configure the project to generate temporary profiling files:
7
8 7 Davide Pesavento
1. Install `gcovr` on your machine: `sudo easy_install gcovr`
9 2
10 7 Davide Pesavento
2. When 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".
11 2
12 6 Davide Pesavento
## To create code coverage report in HTML format, follow these steps:
13 2
14 7 Davide Pesavento
3. After building the project and running unit tests, use `gcovr` to generate detailed code coverage report in html format. The following is a one-liner:
15
`mkdir build/coverage; gcovr -r . --object-directory=build --html --html-details -o build/coverage/coverage.html`
16 2
17
4. Use any browser to open ``build/coverage/coverage.html`` to see the code coverage report.
18
19 6 Davide Pesavento
## To create code coverage report in plain text format, follow these steps:
20 2
21 7 Davide Pesavento
3. After building the project and running unit tests, use `gcovr` to generate detailed code coverage report in plain text. The command is:
22
`gcovr -r . --object-directory=build --html-details -o build/coverage.txt`
23 2
24
4. Use any plain text editor/reader to open ``build/coverage.txt`` to see the code coverage report.
25 3 Yi Huang
26 5 Yi Huang
## To view the detailed code coverage report on Jenkins for builds triggered by Gerrit
27 3 Yi Huang
28
1. Click on the build link that Jenkins posted as a comment on Gerrit.
29
30 6 Davide Pesavento
2. Click on the label "code-coverage" under "Configurations".
31 3 Yi Huang
32
3. Click on "Cobertura Coverage Report" to see the detailed code coverage report for the build.