Search code examples
gradlebuild.gradle

Gradle jacocoTestReport not producing report


I have tried to get code coverage in a spring-gradle project using gradle jacoco plugin.

The build.gradle contains the following

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"
  }
}

I then ran

gradle test jacocoTestReport

Where after only the file test.exec is generated in build/reports folder.

Other than that nothing happens.

How can I get the HTML report?


Solution

  • Following helped . its in samples/testing/jacaco of gradle-2.3-all.zip from https://gradle.org/releases/

    apply plugin: "java"
    
    apply plugin: "jacoco"
    
    jacoco {
        toolVersion = "0.7.1.201405082137"
        reportsDir = file("$buildDir/customJacocoReportDir")
    }
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        testCompile "junit:junit:4.+"
    }
    
    test {
        jacoco {
            append = false
            destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
            classDumpFile = file("$buildDir/jacoco/classpathdumps")
        }
    }
    
    
    jacocoTestReport {
        reports {
            xml.enabled false
            csv.enabled false
            html.destination "${buildDir}/jacocoHtml"
        }
    }