lundi 20 juillet 2020

Jacoco in Android Gradle Project Generates only Execution Report and .exec files, not Coverage Report

I am trying to integrate Jacoco coverage reports with SonarQube. However, my Jacoco is only creating an .exec file along with HTML and XML execution reports. For SonarQube I need coverage reports in XML.

app build.gradle

task jacocoTestReport(type: JacocoReport, dependsOn: 'testDebugUnitTest') {

    group = "Reporting"
    description = "Generate Jacoco coverage reports for the build"

    reports {
//        xml.enabled = true
        xml.destination file("${buildDir}/testDestFolder")
        html.destination file("${buildDir}/testDestFolder")
//        html.enabled = true
    }

    def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
    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("${buildDir}/jacoco/testDebugUnitTest.exec")
}

android {

    testOptions {
        unitTests.all {
            jacoco {
                includeNoLocationClasses = true
            }
        }
    }
...
}

Aucun commentaire:

Enregistrer un commentaire