简体   繁体   中英

JaCoCo agent is not tracking code coverage info

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

解决了,我没有在服务器端和测试端使用相同版本的软件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM