简体   繁体   English

Jacoco 代码覆盖率报告显示错误

[英]Jacoco code coverage report showing wrong

When I run individual test classes, it shows 100% coverage where as when I taken maven build for whole project then Jacoco report showing wrong coverage percentage for many classes.当我运行单个测试类时,它显示了 100% 的覆盖率,而当我为整个项目构建 maven 时,Jacoco 报告显示许多类的覆盖率错误。 Is there a way to get jacaco report per test class?有没有办法通过测试 class 获得 jacaco 报告?

Below is my pom configuration下面是我的pom配置

      <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.6</version>
            <executions>
                <execution>
                    <id>default-prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-report</id>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>  

I followed the steps in below link and it solved the issue.我按照下面链接中的步骤操作,它解决了这个问题。 Note, mine was a multi module project and i wanted code coverage as a single report for all modules.请注意,我的项目是一个多模块项目,我希望将代码覆盖率作为所有模块的单一报告。

https://giri-tech.blogspot.com/2021/08/maven-multi-module-java-project-code.html https://giri-tech.blogspot.com/2021/08/maven-multi-module-java-project-code.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM