Number "lines to cover" Clover vs Jacoco

Must-share information (formatted with Markdown):

  • Sonarqube 8.9.2 LTS. Latest version of Sonar-Clover 4.1 plugin
  • Compare results on the same code base using Jacoco and Clover
  • I have managed to ingest the coverage reports of both but numbers don´t match

Our team has switched from Jacoco to Clover to ingest coverage reports into Sonarqube 8.9.2 Community Edition.

I have performed scans over two different projects with exactly the same code. One project I am using Clover and the project I am using Jacoco.

I have read in some forums that there might be a discrepancy on how the stastistics are calculated but I find weird that the overall “Lines to cover” under Jacoco are around 1k and under Clover are around 250 lines.

Checking the Measures tab under Sonarqube and running through the different packages I find that same java package reports 292 lines to cover in Jacoco based project while it reports only 62 lines to cover under the Clover project.

If I click on the top right “hamburguer” menu the “File measures” option. the number of lines, lines of code and comment lines are exactly the same but on the Coverage column is where the discrepancy shows.

Any idea?

Hey there.

I see you’ve raised an issue on sonar-clover which is the right move since this is a community-supported plugin.

Out of curiosity – why the switch from JaCoCo to Clover?

Thanks @Colin for the quick answer. Because there is now way to use PowerMock with JaCoCo on-the-fly instrumentation as mentioned in this bug

But anyway @Colin I was wondering…Clover plugin is not supported but Jacoco is included in Sonarqube code. I am wondering how the “Lines to cover” are calculated? What does this number mean? Any documentation on that matter? I want to understand what is measured with that number

Hey @mgonzalez

The coverage reports themselves tell SonarQube what lines can be covered by tests (which lines are “executable”). When file is included in a coverage report, we follow these guidelines.

You can see the code for Java yourself.

Executable Lines = Lines to Cover

And – when a coverage report provides information on a file, we listen to the coverage report and ignore this data. It seems like Clover only marks certain lines as being executable, while JaCoCo marks more.

1 Like

Thanks! That clarifies everything. Maybe Lines to Cover is a bit misleading while executable lines is more meaningful

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.