gpt4 book ai didi

gradle jacocoTestReport 不起作用?

转载 作者:行者123 更新时间:2023-12-02 04:10:34 30 4
gpt4 key购买 nike

我尝试使用 gradle jacoco 插件在 spring-gradle 项目中获取代码覆盖率。

build.gradle 包含以下内容

apply plugin: "jacoco"

jacoco {
toolVersion = "0.7.1.201405082137"
reportsDir = file("$buildDir/customJacocoReportDir")
}

jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/jacocoHtml"
}
}

然后我就跑了

gradle test jacocoTestReport

之后,在 build/reports 文件夹中仅生成文件 test.exec。

除此之外什么也没有发生。

如何获取 HTML 报告?

最佳答案

您不必配置reportsDir/destinationFile

因为 jacoco 对它们有默认值。

构建.gradle:

plugins {
id 'java'
id 'jacoco'
}

jacocoTestReport {
reports {
xml.enabled true
html.enabled true
csv.enabled true
}
}

repositories {
jcenter()
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}

运行gradle测试jacocoTestReport

您可以在./build/reports/jacoco/test目录中找到测试报告。

HTML 输出位于 ./build/reports/jacoco/test/html 目录中。

关于gradle jacocoTestReport 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29097393/

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