How to generage .xml or .html with jacoco and spoon


I can setup spoon with:

spoon {
  codeCoverage  true

to generage files.

How can I generate the reports in .xml or .html?


You can do this creating your own task using the built-in Jacoco Gradle plugin:

apply plugin: 'jacoco'

task jacocoTestReport(type: JacocoReport, dependsOn: ['<taskThatProducesEcFile>']) {

    reports {
        xml.enabled  true
        html.enabled  true

    def fileFilter  ['**/R.class', <another filters...>]
    def debugTree  fileTree(dir: "${buildDir}/intermediates/classes/debug",     excludes: fileFilter)
    def mainSrc  "${project.projectDir}/src/main/java"

    sourceDirectories  files([mainSrc])
    classDirectories  files([debugTree])
    executionData  files([<your_path_to_ec_file>])

Answered By – Rafael Toledo

Leave a Comment