gradle build不生成jacoco测试报告

问题描述 投票:0回答:1

在我的gradle构建脚本中,我有一个部分说我在运行任务时生成测试报告:jacocoTestReport

jacocoTestReport {
    group = "build"
    reports {
        xml.enabled false
        csv.enabled false
        html.destination "${buildDir}/reports/coverage"
    }
}

当我运行任务时,它给我一个错误:无法读取执行数据文件.. \ build \ jacoco \ test.exec如何修复此错误。当我在整个项目上进行gradle构建时,我看到测试报告正在生成。

testing gradle report
1个回答
0
投票

您可能需要导入jacoco插件

apply plugin: "jacoco"

我的gradle.build如下,工作正常

apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "idea"
apply plugin: "jacoco"

repositories {
  mavenCentral()
}

dependencies {
  testCompile "junit:junit:4.12"
}

test {
  testLogging {
    exceptionFormat = 'full'
    events = ["passed", "failed", "skipped"]
  }
  finalizedBy jacocoTestReport
}

jacocoTestReport{
  group = "build"
  reports {
    xml.enabled false
    csv.enabled false
    html.destination file("${buildDir}/jacocoHtml")
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.