I have a server application that I run using the following command:
#!/bin/bash
echo "Trying to start Server..."
BASE_DIR=/myapp/environments/myProject_test/web-based/server
echo $BASE_DIR
SERVER_JAR=$(ls $BASE_DIR/my-project-server*.jar | xargs -n 1 basename)
echo $SERVER_JAR
cd $BASE_DIR
/myapp/java/jdk-latest-8/bin/java -Xrs -Xmx1024M -
Dcom.sun.management.jmxremote.port=3333 -
Dcom.sun.management.jmxremote.authenticate=false -
Dcom.sun.management.jmxremote.ssl=false javaagent:/myapp/environments/jacocoagent.jar=append=true,dumponexit=false,output=tcpserver,address=* -jar $BASE_DIR/$SERVER_JAR &
As you can see above, I am using jacoco agent to get the test coverage of the application. I run multiple integration tests that generate .exec files, and after all tests ran I use the following script:
task jacocoDump {
//make jacoco dump task executing always
outputs.upToDateWhen { false }
doLast {
ant {
taskdef(name: "jacocoDumpAnt",
classname: "org.jacoco.ant.DumpTask",
classpath: configurations.jacocoAnt.asPath)
}
def jacocoDestFile = "${project.projectDir}/server.exec"
ant.jacocoDumpAnt(address:"localhost",
reset:"true",
destfile:jacocoDestFile,
append:"false")
}
}
...
jacocoTestReport {
onlyIf { !project.hasProperty("skipJacocoTestReport") }
// Checking for the exec data. This is to make sure the build works locally on developer machines where the exec file doesn't exist.
def execFile = file("${project.projectDir}/_test/Tests/server.exec")
if (execFile.exists()) {
executionData(execFile)
}
reports {
xml.enabled true
}
}
The coverage for unit tests is working just fine, but the coverage for the remote application does not work. I mean, it does not show any coverage. I am kind of stuck on it and have tried many different configurations and no way to get the coverage working. Btw, I am uploading it afterward in sonarqube.