How do I know if the "jacoco.exec" was uploaded?

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube: Version 6.7.5 (build 38563

  • what are you trying to achieve
    I’m pretty new to Sonarqube and Jacoco. I was able to get the JUnit test coverage uploaded to Sonarqube, and now I want to have functional end-to-end test coverage reported.

  • what have you tried so far to achieve this
    To run the Java VM (which is a web server), I run it with the Jacoco java agent using this:
    -javaagent:jacocoagent.jar=output=tcpserver

Then, I use the jacococli to download the execution data and save it to .out/jacoco-it.exec
After run the gradle sonarqube task, I then revisited our internally hosted sonarqube web instance.
It appears that the code coverage did not go up, as expected. It stayed exactly the same.

How can I be sure that the jacoco-it.exec file I downloaded actually made it to the Sonar server?

I also created the following gradle task to run after our integration tests run to download the data.
It feels a little hacky to me… is there a better way of doing this natively with Sonarqube?

task integCoverage(type: JavaExec) {
def address = System.properties[‘address’]
def port = System.properties[‘port’]
if (address && port) {
main = ‘org.jacoco.cli.internal.Main’
classpath = sourceSets.main.runtimeClasspath
args ‘dump’, ‘–address’, address, ‘–port’, port, ‘–destfile’, “$buildDir/jacoco-it.exec”
}
}

hello @Neil_Hunter,

when you execute gradle you can pass --info and then you should see logs like these

Sensor JaCoCoSensor [java]
Analysing C:\projects\sonar-scanning-examples\sonarqube-scanner-gradle\build\jacoco\test.exec
No information about coverage per test.
Sensor JaCoCoSensor [java] (done) | time=64ms

Note however, that binary “exec” format for JaCoCo has been deprecated. I would suggest to upgrade to use XML JaCoCo report as described here https://www.sonarsource.com/resources/product-news/news.html#sonarjava-5-12