问题
I have looked around the net with lot of information regarding the topic scattered but not one that fits my need.
I plan to measure the coverage of system test cases. Our system test cases run in a clustered environment supported by Tomcat server. So in different JVM. There are multiple instance of Tomcat running where system test cases run, hence I get multiple jacoco bump files at each Tomcat.
I am attaching jacoco agent jar to tomcat startup as VM argument: -javaagent:org.jacoco.agent-runtime.jar=destfile=jacoco.exec,append=true
I have maven set up to run the system test cases(once triggered the test runs in deployed tomcat server). I use fail safe plugin for this. I collect the different jacaco files post test case execution and get a merged jacoco file with below plugin setup.
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<configuration>
<fileSets>
<fileSet>
<directory>jacoco-execs</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
</fileSets>
<!-- File containing the merged data -->
<destFile>../jacoco-merged/merged.exec</destFile>
</configuration>
</plugin>
In sonar pom I supply the location of this merged jacoco exec to get the coverage report. ../merged.exec
With the set up I manage to get the line coverage report in sonar board however I do not get coverage per test and sonar logs have below error "No information about coverage per test."
I am aware that I must attach a jacoco listener to get this information. I am facing problem in doing so as I do not generate the jacoco file using maven but by attaching jacoco agent to tomcat startup via vm arguments. Is there a way to add a listener via VM argument, the way we add the javaagent?
Please advise.
来源:https://stackoverflow.com/questions/34924996/coverage-per-test-jacoco-tomcat-and-sonar