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

jacoco

(Neil Hunter) #1

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?


(Neil Hunter) #2

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”
}
}