Add coverage of integration test to sonar

I have project A which is in this structure:


| Backend code( contain unit test) this will build and deploy in wildfly container in docker

| integration test( call to BE code)

My project already had sonar to show coverage of unit test but right now I want to show integration test as well.

I have checked a lot of answer in google and came up quick this solution.
– (1) copies the jacoco runtime jar into a volume that’s shared with the docker container
to do this I have update my docker file to

       - JAVA_OPTS=-javaagent:/opt/wildfly/jacocoagent.jar=destfile=/tmp/jacoco/jacoco.exec,output=tcpserver,address=*
  • (2) Run test so that jacoco will generate jacoco-it.exec file and fill up data in jacoco.exec
  • (3) Mount file jacoco.exec so that sonar can scan and show.

Here is my gradle file

sonarqube {
        properties {
            property "sonar.junit.reportPaths", "${project.buildDir}/test-results, ${project.buildDir}/test-results/test"
            property "sonar.jacoco.reportPaths", "${project.buildDir}/jacoco/test.exec"
            property "sonar.jacoco.itReportPath", "${project.buildDir}/jacoco/testIntegration.exec"

Right now I’m in step 1, I can see that the jacocoagent.jar has run and listening with port 6300.
but the file jacoco.exec it’s not created at the time I start the container.

I don’t know Is that all the step here correct or not? and Will the file jacoco.exec being created right after the time I start the container?

Source: StackOverflow