Search code examples
jenkinscontinuous-integrationcoberturagcovgcovr

Output color code of Gcov with Cobertura


I have set gcov code coverage tools on Jenkins.

This works fine, but I have troubles undertanding the ouput color code. The number of 'hits' of each line is corect, but some line are green when others are red, and I can't tell why.

Example :

enter image description here

Note that the setYear method is all green, and called 13 times (ctor + 12 times in setDateAAMMJJ as you can see on the screen cap)


Solution

  • If you look at the source code for the cobertura-plugin on github you will see that:

    table.source tr.coverPart td.hits, table.source tr.coverNone td.hits {
        background-color: #fdd;
        font-weight: bold;
    }
    

    and

    table.source tr.coverPart {
        background-color: #ffd;
    }
    
    • #fdd is the red color,
    • #ffd is the yellow color

    You should be able to use your browser 'developer tools' or 'inspector' function to see which class is applied.

    What does it mean?

    The yellow on the far left means the source code is covered partly, that means you probably don't have 100% coverage in the functions that are being called.

    Another case I can think of (pure speculation at this point) is that some optimization is mangling your statement coverage; check your compilation flags.

    If you kept the data (lcov files), you should be able to use genhtml to generate a report and compare.