Java Jacoco代理不测量任何代码覆盖率
在maven构建过程中,我使用process exec maven插件启动我的应用程序,并使用Failsafe运行集成测试。现在我想从测试中的应用程序中获取覆盖率数据 问题是,覆盖率报告包含我的应用程序的所有类,但没有覆盖率数据0%。 当我将jacoco代理附加到failsafe插件时,它会生成测试类的代码覆盖率,这并没有真正的帮助 有什么想法吗 process exec maven插件配置: 使用以下Jacoco配置:Java Jacoco代理不测量任何代码覆盖率,java,maven,jacoco-maven-plugin,Java,Maven,Jacoco Maven Plugin,在maven构建过程中,我使用process exec maven插件启动我的应用程序,并使用Failsafe运行集成测试。现在我想从测试中的应用程序中获取覆盖率数据 问题是,覆盖率报告包含我的应用程序的所有类,但没有覆盖率数据0%。 当我将jacoco代理附加到failsafe插件时,它会生成测试类的代码覆盖率,这并没有真正的帮助 有什么想法吗 process exec maven插件配置: 使用以下Jacoco配置: 在我的例子中,问题是服务器与docker容器一起以HW断电方式运行-没有像
在我的例子中,问题是服务器与docker容器一起以HW断电方式运行-没有像SIGTERM这样的信号,它依赖于docker容器中运行的JVM的JaCoCo端的输出
当我添加docker在docker容器内运行的killall java命令,并在关闭容器之前稍作停顿时,exec文件正常。问题似乎只在本地出现,对于我们的构建服务器,此配置工作正常。不知道为什么-我会关注它。它似乎没有将jacocoagent.jar附加到目标JVM Tomcat/etc。一旦完成,那么在目标JVM Tomcat实例停止后,.exec文件大小将成功填充。检查单元和非单元IT测试:
<plugin>
<groupId>com.bazaarvoice.maven.plugins</groupId>
<artifactId>process-exec-maven-plugin</artifactId>
<executions>
<execution>
<id>start-importer</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<name>product-importer</name>
<waitForInterrupt>false</waitForInterrupt>
<healthcheckUrl>http://localhost:${jetty.http.port}/health</healthcheckUrl>
<arguments>
<argument>${java.home}/../bin/java</argument>
<argument>${failsafe.argLine}</argument>
<argument>-jar</argument>
<argument>
${project.build.directory}/jars/app-${project.version}-shaded.jar
</argument>
</arguments>
</configuration>
</execution>
<!--Stop all processes in reverse order-->
<execution>
<id>stop-all</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-all</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-jacoco-service-test-agent</id>
<!-- default pre-integration is to late for the process-exec-maven-plugin -->
<phase>package</phase>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
<propertyName>failsafe.argLine</propertyName>
<includes>
<include>de.myapp.*</include>
</includes>
<classDumpDir>${project.build.outputDirectory}</classDumpDir>
<destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>
<append>true</append>
</configuration>
</execution>
<execution>
<id>report-jacoco-service-test-results</id>
<goals>
<goal>report-integration</goal>
</goals>
<phase>verify</phase>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile>
<outputDirectory>${project.build.directory}/coverage-reports/out/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>