gpt4 book ai didi

gradle - 找不到方法 jacocoTestCoverageVerification()

转载 作者:行者123 更新时间:2023-12-04 22:56:08 27 4
gpt4 key购买 nike

当测试覆盖率不够时,我想让 jacoco 插件失败。我使用 gradle 页面中的示例:
https://docs.gradle.org/current/userguide/jacoco_plugin.html

apply plugin: 'jacoco'

jacoco {
toolVersion = "0.7.6.201602180812"
reportsDir = file("output/jacoco/customJacocoReportDir")
}

jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.enabled true
html.destination file("output/jacoco/jacocoHtml")
}
}

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

rule {
enabled = false
element = 'CLASS'
includes = ['org.gradle.*']

limit {
counter = 'LINE'
value = 'TOTALCOUNT'
maximum = 0.3
}
}
}
}

但是,我收到错误:

Could not find method jacocoTestCoverageVerification() for arguments [build_4v41fim1xdl76q49oxk7mnylv$_run_closure6@18601994] on root project 'demo' of type org.gradle.api.Project.



任何人都可以建议吗?

最佳答案

根据the docs对于 Gradle 3.4 或更高版本 :

For projects that also apply the Java Plugin, The JaCoCo plugin automatically adds the following tasks:

jacocoTestReport [...]

jacocoTestCoverageVerification [...]


如果您问题中的代码块显示您的完整 build.gradle文件,这意味着您需要添加应用 Java 插件的行 ( apply plugin: 'java' )。
当然,您也可以添加 JacocoCoverageVerification 类型的任务。调用 jacocoTestCoverageVerification到您自己的构建文件:
task jacocoTestCoverageVerification(type: JacocoCoverageVerification) {
// configuration
}

关于gradle - 找不到方法 jacocoTestCoverageVerification(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46022885/

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