1

I have a Java web application running on a Wildfly 9 server and I use the jmeter-maven-plugin to run some performance tests on the running instance of my application. Those tests run simple REST requests to my application's services.

What I would like to do is retrieve the code coverage statistics of the performance tests so that I always know what is the amount of covered code of my performance tests.

Following this, this and this StackOverflow threads I setup the JaCoCo Java agent on the server. This is the agent configuration at startup

set "JAVA_OPTS=%JAVA_OPTS% -javaagent:/path/to/jacocoagent.jar=output=tcpserver,address=*,port=6300,includes=my.package.*"

Also, I configured the jacoco-maven-plugin on the tests Maven project in order to let it run a dump on the server to retrieve the execution information.

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.7.7.201606060606</version>
    <configuration>
        <destFile>${sonar.jacoco.itReportPath}</destFile>
        <append>false</append>
    </configuration>
    <executions>
        <execution>
            <id>jacoco-dump</id>
            <phase>verify</phase>
            <goals>
                <goal>dump</goal>
            </goals>
            <configuration>
                <address>my.server</address>
                <skip>${skipJMeterTests}</skip>
                <!-- <reset>true</reset> -->
            </configuration>
        </execution>
    </executions>
</plugin>

So, when I run mvn verify all performance tests run (so the REST services are indeed called) and the JaCoCo plugin correctly dumps the server jacoco.exec file, but when I inspect this file running mvn sonar:sonar I get a 0% coverage of code even though the services were called by the performance tests.

What could be the problem? I tried different configurations of the agent and plugin but seemed to not solve my problem.

Thank you

gvdm
  • 3,006
  • 5
  • 35
  • 73
  • Multiple things you could verify. 1) Are the runtime classes same version as the classes on which you are running the report? 2) Is your server startup file also invoking any other Java agent ahead of Jacoco (eg: Wiley Introscope) ? This may cause issues as jacoco must be getting classes instrumented by the other agent. – Shashank Kadne Oct 11 '16 at 14:13
  • How to you find out the coverage? A plugin in the server determining the coverage may have a version issue. JaCoCo changes the exec format in 0.7.5. If using current JaCoCo version you have to use an up to date sonar plugin. I remember same problem with JaCoCo plugin for Jenkins. – Arne Burmeister Oct 11 '16 at 14:16
  • @ShashankKadne: 1) yes, the versions are the same. 2) No, there is no other javaagent running on the server. – gvdm Oct 11 '16 at 14:42
  • @ArneBurmeister: I "read" the jacoco files using the Eclipse plugin for EclEmma Java Code Coverage v2.3.3. The Jacoco agent version I'm using is the last, 0.7.7. – gvdm Oct 11 '16 at 14:44
  • @ArneBurmeister: I'm also viewing the statistics in my Sonar instance, which is up to date at the last release – gvdm Oct 11 '16 at 14:44

1 Answers1

0

Solved, I was not using the same version of the software on both server and test side

gvdm
  • 3,006
  • 5
  • 35
  • 73