Skip to content

Instantly share code, notes, and snippets.

@goofyahead
Last active June 26, 2018 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goofyahead/86cd74934b047b94b7df5a409e065122 to your computer and use it in GitHub Desktop.
Save goofyahead/86cd74934b047b94b7df5a409e065122 to your computer and use it in GitHub Desktop.
task codeCoverageReport(type: JacocoReport, dependsOn: 'testStagingDebugUnitTest') {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
reports {
xml.enabled = true
html.enabled = true
}
classDirectories = fileTree(
dir: 'build/intermediates/classes/staging/debug/com/yourpackage',
excludes: androidExclusion
)
sourceDirectories = files('src/main/java/yourpackage')
executionData = files('build/jacoco/testStagingDebugUnitTest.exec')
}
task getCoverage(type: Exec, dependsOn: 'codeCoverageReport') {
group = "Reporting"
commandLine "open", "$buildDir/reports/jacoco/codeCoverageReport/html/index.html"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment