Jacoco测试报告中的差异

发布于 2025-02-03 12:46:39 字数 1163 浏览 3 评论 0原文

我有一个年级项目,我将某些文件排除在Jacoco报告中。当我运行命令Gradle JacocotestReport时。显示下面的输出。

Test Coverage:
    - Class Coverage: 84.2%
    - Method Coverage: 80%
    - Branch Coverage: 59.1%
    - Line Coverage: 81.8%
    - Instruction Coverage: 80.8%
    - Complexity Coverage: 62.7%

但是,当我运行Gradle Build时。我会收到以下错误: -

Execution failed for task ':project:jacocoTestCoverageVerification'.
> Rule violated for bundle project: instructions covered ratio is 0.5, but expected minimum is 0.8

build.gradle: -

test {
    useJUnitPlatform()
    finalizedBy jacocoTestReport
}

jacocoTestReport {
    afterEvaluate {
        classDirectories.setFrom(files(classDirectories.files.collect {
            fileTree(dir: it,  exclude: [
                    "com/project/commons/infrastructure/**"
            ])
        }))
    }
    finalizedBy jacocoTestCoverageVerification
}

jacocoTestCoverageVerification {
    violationRules {
        rule {
            limit {
                minimum = 0.8
            }
        }
    }
}

有人可以告诉我为什么有差异吗?

I have a grade project and I have excluded certain files from Jacoco reporting. When I run the command gradle jacocoTestReport. Below output is shown.

Test Coverage:
    - Class Coverage: 84.2%
    - Method Coverage: 80%
    - Branch Coverage: 59.1%
    - Line Coverage: 81.8%
    - Instruction Coverage: 80.8%
    - Complexity Coverage: 62.7%

But when i run gradle build. I get the below error:-

Execution failed for task ':project:jacocoTestCoverageVerification'.
> Rule violated for bundle project: instructions covered ratio is 0.5, but expected minimum is 0.8

build.gradle:-

test {
    useJUnitPlatform()
    finalizedBy jacocoTestReport
}

jacocoTestReport {
    afterEvaluate {
        classDirectories.setFrom(files(classDirectories.files.collect {
            fileTree(dir: it,  exclude: [
                    "com/project/commons/infrastructure/**"
            ])
        }))
    }
    finalizedBy jacocoTestCoverageVerification
}

jacocoTestCoverageVerification {
    violationRules {
        rule {
            limit {
                minimum = 0.8
            }
        }
    }
}

Can anyone please tell me why is there a discrepancy ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文