英文:
Jacoco Maven coverage report always 0%
问题
我在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)。
提前感谢您的帮助!
英文:
I've this problem with Jacoco maven plugin in IntelliJ IDEA 2020.
I put the Jacoco plugin configuration in my pom.xml maven file and then executed the mvn clean install
command. It generates the target\site folder but when I open the index.html file it shows me a coverage of 0%, listing all my classes, although I get a 92% coverage in IntelliJ's integrated tool. The jacoco.exec file is generated in target folder, but it's empty!
How can I fix this issue?
Here's my pom.xml fragment:
<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>
I'm using the latest Java version (14).
Thanks in advance!
专注分享java语言的经验与见解,让所有开发者获益!
评论