Andre Perkins
Andre Perkins

Reputation: 7800

How to exclude packages from code coverage report?

I currently am using the createDebugAndroidTestCoverageReport to run my android instrumentation tests and generate a coverage report. The only issue that I am running into is that there are packages that are generated from Realm and Databinding and these classes are also being included in my coverage report. How can I configure jacoco to exclude these packages?

Upvotes: 4

Views: 3323

Answers (2)

ImMathan
ImMathan

Reputation: 4971

When you are defining the debugTree you can add the fileFilters to be excluded.

task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
 reports {
      xml.enabled = true
      html.enabled = true
 }
 def fileFilter = ['**/package/**']
 def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/debug", excludes: fileFilter)
}

Upvotes: 0

Testing Singh
Testing Singh

Reputation: 1353

test {
    jacoco {
        append = false
        destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
        classDumpFile = file("$buildDir/jacoco/classpathdumps")
        excludes = []
    }
}

Click here for more details on official Jacoco Gradle Plugin

Upvotes: 0

Related Questions