5

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)

MokaT
  • 1,416
  • 16
  • 37

2 Answers2

2

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.

dnozay
  • 23,846
  • 6
  • 82
  • 104
  • Thanks to you for the answer. The crazy things is that both of the red functions had 100% coverage, since, we added 2 unit tests, coverage is gone to 14 times instead of 12, and now it's all green. It might be a little bug ? genhtml generate the same report. – MokaT Mar 13 '15 at 13:00
  • I have this issue as well, not sure, if this is a gcov, gcovr or cobertura issue – Simon Apr 29 '15 at 12:12
  • I've checked. It's not cobertura, since the gcovr HTML export is the same. – MokaT Apr 29 '15 at 12:49
  • Any solutions since 2013? – Simon Apr 29 '15 at 12:51
1

Don't know if this applies for you but it seems relevant. In my case it is red because branch cover is not 100%. When generating an xml with gcovr it also adds branch cover data.

It is possible to cover all the lines but not cover all the branches. Im having all kinds of problems with the branch cover.

Some are described in these posts.

Why gcc 4.1 + gcov reports 100% branch coverage and newer (4.4, 4.6, 4.8) reports 50% for "p = new class;" line?

What is the branch in the destructor reported by gcov?

Still looking for a way to solve issues like these..

rinn2883
  • 366
  • 1
  • 14