我在IntelliJ IDEA 2020中使用Jacoco maven插件遇到了这个问题。
我将Jacoco插件配置放入我的pom.xml maven文件中,然后执行了mvn clean install
命令。它生成了target \ site文件夹,但是当我打开index.html文件时,它显示的覆盖率为0%,列出了所有类,尽管IntelliJ集成工具的覆盖率为92%。 jacoco.exec文件在目标文件夹中生成,但是为空!
我该如何解决这个问题?
这是我的pom.xml片段:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>14</source>
<target>14</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<configuration>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
<goal>check</goal>
</goals>
<configuration>
<rules>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
我正在使用最新的Java版本(14)。 预先感谢!