Jacoco Maven覆盖率报告始终为0%。

huangapple 未分类评论50阅读模式
英文:

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:

    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
        &lt;configuration&gt;
          &lt;source&gt;14&lt;/source&gt;
          &lt;target&gt;14&lt;/target&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
        &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt;
        &lt;version&gt;0.8.5&lt;/version&gt;
        &lt;configuration&gt;
          &lt;excludes&gt;
            &lt;exclude&gt;META-INF/**&lt;/exclude&gt;
          &lt;/excludes&gt;
        &lt;/configuration&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;id&gt;pre-unit-test&lt;/id&gt;
            &lt;goals&gt;
              &lt;goal&gt;prepare-agent&lt;/goal&gt;
            &lt;/goals&gt;
          &lt;/execution&gt;
          &lt;execution&gt;
            &lt;id&gt;post-unit-test&lt;/id&gt;
            &lt;phase&gt;test&lt;/phase&gt;
            &lt;goals&gt;
              &lt;goal&gt;report&lt;/goal&gt;
              &lt;goal&gt;check&lt;/goal&gt;
            &lt;/goals&gt;
            &lt;configuration&gt;
              &lt;rules&gt;
              &lt;/rules&gt;
            &lt;/configuration&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;

I'm using the latest Java version (14).
Thanks in advance!

huangapple
  • 本文由 发表于 2020年5月4日 21:24:30
  • 转载请务必保留本文链接:https://java.coder-hub.com/61593299.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定