CodeCoverage » History » Version 4
Yi Huang, 03/18/2014 05:46 PM
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 | 1. Install ``gcovr`` on your machine. <pre><code>sudo easy_install gcovr</code></pre> |
||
9 | |||
10 | 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". For example, ``ndn-cpp-dev`` requires ``ndnd-tlv`` to run its unit tests, then when configuring ``ndn-cpp-dev``, we should use "``./waf configure --with-tests --with-coverage``", and when configuring ``ndnd-tlv``, we should use "``./waf configure --with-coverage``". |
||
11 | |||
12 | ## To create code coverage report (HTML format) follow the steps below: |
||
13 | |||
14 | 3. 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: |
||
15 | <pre><code>mkdir build/coverage; gcovr -r . --object-directory=build/ --html --html-details -o build/coverage/coverage.html</code></pre> |
||
16 | |||
17 | 4. Use any browser to open ``build/coverage/coverage.html`` to see the code coverage report. |
||
18 | |||
19 | ## To create code coverage report (PLAIN TEXT) follow the steps below: |
||
20 | |||
21 | 3. After building the project and running unit tests, use ``gcovr`` to generate detailed code coverage report in plain text. The command is: |
||
22 | <pre><code>gcovr -r . --object-directory=build/ --html-details -o build/coverage.txt</code></pre> |
||
23 | |||
24 | 4. Use any plain text editor/reader to open ``build/coverage.txt`` to see the code coverage report. |
||
25 | 3 | Yi Huang | |
26 | ##To view the detailed code coverage report on Jenkins for builds triggered by Gerrit |
||
27 | |||
28 | 1. Click on the build link that Jenkins posted as a comment on Gerrit. |
||
29 | |||
30 | 2. Click on the label "code-coverage" under "Configuration" |
||
31 | |||
32 | 3. Click on "Cobertura Coverage Report" to see the detailed code coverage report for the build. |