1

In my gradle build script, I have a section which says to generate a test report when I run task : jacocoTestReport

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

When I run the task, it gives me an error : Unable to read execution data file ..\build\jacoco\test.exec How can I fix this error. When I do gradle build on the complete project, I see test report is getting generated.

user1015388
  • 1,283
  • 4
  • 25
  • 45
  • If the problem continues despite of applying the workarounds, you may have a look at my answer on [maven jacoco: not generating code coverage report](https://stackoverflow.com/questions/25395255/maven-jacoco-not-generating-code-coverage-report/71661614#71661614). – Murat Yıldız Mar 29 '22 at 12:03

1 Answers1

1

You may need to import jacoco plugin

apply plugin: "jacoco"

My gradle.build as follows and working fine

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")
  }
}
nayakam
  • 4,149
  • 7
  • 42
  • 62
  • My gradle script already has jacoco plugin. ... apply plugin: 'eclipse' apply plugin: 'jacoco' apply plugin: 'war' jacocoTestReport { group = "build" reports { xml.enabled false csv.enabled false html.destination "${buildDir}/reports/coverage" } } – user1015388 Apr 03 '19 at 13:22
  • Specify jacaco tool version as mentioned in https://docs.gradle.org/current/userguide/jacoco_plugin.html – nayakam Apr 03 '19 at 21:28