Skip to content

Instantly share code, notes, and snippets.

@TedaLIEz
Forked from vlad-kasatkin/build.gradle
Created February 22, 2017 15:11
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 TedaLIEz/6a21562f30892ac9df2765583cc75970 to your computer and use it in GitHub Desktop.
Save TedaLIEz/6a21562f30892ac9df2765583cc75970 to your computer and use it in GitHub Desktop.
jacoco task for espresso coverage
apply plugin: 'jacoco'
jacoco {
version "0.7.1.201405082137"
}
task jacocoTestReportAndroidTest(type: JacocoReport, dependsOn: "connectedAndroidTest") {
def coverageSourceDirs = [
'src/main/java'
]
group = "Reporting"
description = "Generates Jacoco coverage reports"
reports {
csv.enabled false
xml{
enabled = true
destination "${buildDir}/reports/jacoco/jacoco.xml"
}
html{
enabled true
destination "${buildDir}/jacocoHtml"
}
}
classDirectories = fileTree(
dir: 'build/intermediates/classes',
excludes: ['**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Activity*.*',
'**/*Fragment*.*'
]
)
sourceDirectories = files(coverageSourceDirs)
additionalSourceDirs = files(coverageSourceDirs)
if (project.hasProperty('coverageFiles')) {
// convert the comma separated string to an array to create an aggregate report from
// multiple coverage.ec files
def coverageFilesArray = coverageFiles.split(',')
executionData = files(coverageFilesArray)
}
else {
executionData = files('build/outputs/code-coverage/connected/coverage.ec')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment