【发布时间】:2019-04-16 21:21:08
【问题描述】:
不明白,我尝试用JaCoCo和Maven生成代码覆盖率报告,最简单的。
我的 pom.xml 中有以下插件:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>target/jacoco.exec</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>target/my-reports</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
当我尝试做一个 mvn 测试时,它什么也没做。甚至没有错误或其他东西。它说为我的测试建立成功但 Maven 似乎没有看到 JaCoCo。如果我尝试执行 mvn jacoco:report 无论如何我有一条消息:Skipping JaCoCo execution due to missing execution data file.
【问题讨论】:
标签: maven code-coverage jacoco