gpt4 book ai didi

java - 从 jacoco 覆盖率报告中排除 jar 文件类

转载 作者:搜寻专家 更新时间:2023-10-31 20:10:37 24 4
gpt4 key购买 nike

Jacoco 代码覆盖率报告还包括来自“系统路径 jar”的类,我使用下面的 maven 依赖项添加了这些类

<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.2.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/axis-1.2.1.jar</systemPath>
</dependency>

我试图像这样从 jacoco 插件中排除这个 jar 的文件:

            <plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.2.201409121644</version>
<configuration>
<excludes>
<exclude>**/org/apache/**/*</exclude>
<exclude>**/org/globus/**/*</exclude>
</excludes>
</configuration>

<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<destFile>${project.build.directory}/coverage-reports/jacoco.exec</destFile>
<!-- Sets the name of the property containing the settings for JaCoCo
runtime agent. -->
<propertyName>surefireArgLine</propertyName>
</configuration>
</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>${project.build.directory}/coverage-reports/jacoco.exec</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

但是排除不起作用。它仍然显示 jar 中包含的文件的覆盖率报告。如图所示,org.apacke.org.clobus. 包中的文件不应该出现在报道报告中。

enter image description here

最佳答案

我找到了答案

 <exclude>**/lib/*</exclude>

上述排除从我的 jar 文件中排除了 system 范围内的类。

关于java - 从 jacoco 覆盖率报告中排除 jar 文件类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30727952/

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