Gcov color output code with Cobertura

I installed gcov code coverage tools on Jenkins.

This works great, but I'm having problems with the color code. The number of “strokes” of each line is corect, but some lines are green if others are red, and I cannot understand why.

Example:

enter image description here

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

+5
source share
2 answers

If you look at the source code of 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 - red color,
  • #ffd - yellow

You can use the browser’s "developer tools" function or the "inspector" to find out which class is applied.

What does it mean?

Yellow in the far left corner means that the source code is partially covered, this means that you probably do not have 100% coverage in the called functions.

Another case that I can think of (pure speculation at this stage) is that some optimization affects the scope of your application; check your compilation flags.

If you saved the data (lcov files), you can use genhtml to create a report and compare.

+2
source

I do not know if this applies to you, but it seems relevant. In my case, it is red, because the branch cover is not 100%. When generating xml with gcovr, it also adds branch cover information.

You can cover all lines, but not cover all branches. I have all the problems with the branch cover.

Some of them are described in these posts.

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

What is the branch in the destructor reported by gcov?

Looking for a way to solve such problems.

+1
source

Source: https://habr.com/ru/post/1213033/


All Articles