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