gpt4 book ai didi

maven - 使用Maven生成JaCoCo报告

转载 作者:行者123 更新时间:2023-12-03 23:28:21 25 4
gpt4 key购买 nike

我已经在jacoco.exec文件中捕获了覆盖率详细信息。它的大小为6Mb。
我需要使用maven生成一份覆盖率报告。
我尝试了以下

  <dependencies>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.ant</artifactId>
<version>0.7.0.201403182114</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.3.201306030806</version>
<executions>
<!--
Ensures that the code coverage report for integration tests after
integration tests have been run.
-->
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>D:/JaCoCo/jacoco.exec</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>


它正在生成零百分比的覆盖率报告。

在测试之前,jacoco.exec文件的大小为零字节,现在为6MB。
pom.xml中缺少什么吗?

最佳答案

这是jacoco插件配置。

          <plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.5.10.201208310627</version>
<configuration>
<skip>${maven.test.skip}</skip>
<output>file</output>
<append>true</append>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>



在运行 maven:test时将生成jacoco.exec文件
在运行 jacoco:report时,它将在target / site / jacoco目录下的html文件中生成报告。您可以通过打开index.html查看报告

关于maven - 使用Maven生成JaCoCo报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22836455/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com