Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 589
MokaT Avatar asked Oct 20 '22 17:10

MokaT


2 Answers

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..

like image 39
rinn2883 Avatar answered Nov 03 '22 03:11

rinn2883


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.

like image 142
dnozay Avatar answered Nov 03 '22 01:11

dnozay