Coverage data show 0% not consistent with JaCoCo exec file showing ~ 45%


We’re using Version 7.7 (build 23042 ) and running Sonar analysis using both a multi module maven project and a separate integration test coverage exec file generated using a Java Agent as standard and referencing with the property sonar.jacoco.reportPaths.

Unfortunately the sonar dashboard shows 0.9% coverage for Java files where if we use the JaCoCo tool

java -jar jacococli.jar execinfo jacoco_merged.exec

We see output such as

Session “app-670db988”: Wed Jul 31 09:16:08 BST 2019 - Wed Jul 31 10:39:41 BST 2019
1175e272f4c3f6bf 652 of 1390 com/mycomp/product/services/rest/tablemaint/TableMaintService

Which indicates ~40% coverage which is similar to what we’d expect

I added sonar.verbose but didn’t see any obvious messages to indicate why it’s processed in this way

Appreciate your thoughts


What’s interesting is I’ve noticed if I use


The JaCoCo unit test files generated from the maven sonar:sonar build don’t appear to be used e.g. without this property we were getting

[INFO] Analysing /Users/project/source/git/source/mymodule/target/jacoco.exec
[INFO] Sensor JaCoCoSensor [java] (done) | time=162ms
[INFO] Sensor JavaXmlSensor [java]
[INFO] 1 source files to be analyzed

However when the -D property and the integration test external generated exec file is used this entry isn’t present.

Also when we use the -D property and reference the integration test exec file we see it is referenced for most modules such as

[INFO] Sensor JaCoCoSensor [java]
[WARNING] Property ‘sonar.jacoco.reportPaths’ is deprecated (JaCoCo binary format). ‘sonar.coverage.jacoco.xmlReportPaths’ should be used instead (JaCoCo XML format).
[INFO] Analysing /Users/Downloads/jacoco_it_merged.exec
[[INFO] Sensor JaCoCoSensor [java] (done) | time=1219ms

However in one of the modules in our multi module project it isn’t included at all and we can’t see why

hello @mattadamson,

can you try to run the analysis with debug logs? (mvn -X sonar:sonar) Also, do you produce in your build xml report for JaCoCo? If so, binary report will be ignored, and only xml report will be considered. Have a look at the guide here [Coverage & Test Data] Importing JaCoCo coverage report in XML format

Thanks @saberduck

I used -Dsonar.verbose which I thought would be equivalent to -X? We don’t use XML reports only exec. I know XML reports is preferred however exec is our current process and should work even though deprecated?

It’s also interesting I tried merging all exec files including unit test produced by maven into a single exec file. Even when that exec file indicates say ~50% of probes visited for a file Sonar still only shows a very low e.g. 2% of coverage. To help us diagnose

  1. Is there a way to see how the metrics get imported into Sonar in more detail e.g. that file with 50% of probes visiteed?
  2. Is there a way to see in Sonar when stored whether it considers 50 or 2% of coverage for the file and where / why it thinks it’s covered in that way?
  3. In the Sonar UI I presume there won’t be any issues as its’ just reporting from a Sonar REST API its using which queries the database? We can also query any of the oracle databases if it helps you diagnose?

Many thanks


I’ve just tested, and in fact sonar.verbose doesn’t work with maven. This is perhaps something we should fix in the maven scanner. Can you try to use mvn -X, it should print more information about processing of coverage reports.

You can see the coverage information in the measures -> coverage as usual. UI shows the same data as Web API. (I am not sure I understand your question)

Thanks @saberduck sure I’ll do that. Can I email you the logs privately please as I don’t want to distribute here?

You can sent me a private message through this forum

thanks @saberduck I’ve sent all files directly. appreciate the help!

I am closing this topic, because there is no activity, feel free to create a new topic if there is some issue.