code-coveragecoveralls

How to show branch coverage for C++ project on coveralls.io?


I am using the coveralls.io service to display line coverage for my C++ project. I also want to track branch coverage, but cannot get it to work.

On Travis CI, I use this call to generate the coverage report:

coveralls -r <my_project_root> -b <my_build_dir> --verbose --gcov=gcov --gcov-options '\-lpbc';

The coveralls script is previously installed with pip

pip install cpp-coveralls urllib3[secure]

I get the line coverage shown correctly on coveralls.io, but not the branch coverage. I don't know what of the following things I am doing wrong.


Solution

  • Pretty late to the party, but to answer your question(s):

    Yes, you will want to enable the Coveralls setting for BRANCH COVERAGE: INCLUDE IN AGGREGATE %:

    coveralls setting - branch coverage

    Of course, this will only work if branch coverage is included in your original coverage report.

    That happens in a prior step, when you compile the original project into an "instrumented" version of the source code and generate the GCOV coverage report, before you use the coveralls command to POST the coverage report to Coveralls.

    Something like:

    
        gcc -Wall -ftest-coverage -fprofile-arcs cov.c
        gcov --branch-probabilities cov.c
    
    

    Source: gcov Wiki - Example