Skip to content

Instantly share code, notes, and snippets.

@josomers
Last active November 10, 2017 14:42
Show Gist options
  • Save josomers/9f90b017e321c54bb918 to your computer and use it in GitHub Desktop.
Save josomers/9f90b017e321c54bb918 to your computer and use it in GitHub Desktop.
Test coverage with Jacoco on Android gradle project with injection frameworks like Dagger/Butterknife and Robolectric 2.3
apply plugin: 'jacoco'
apply plugin: 'idea'
jacoco {
toolVersion = "0.7.0.201403182114"
}
jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
classDirectories = fileTree(
dir: '../my-project/build/intermediates/classes/debug',
exclude: [
'**/R*.class',
'**/BuildConfig*',
'**/*$*.class',
'**/*$*.java']
)
additionalSourceDirs = files([
'../my-project/src/main/java',
'../my-project/build/generated/source/buildConfig/debug',
'../my-project/build/generated/source/r/debug'])
executionData = files('build/jacoco/testDebug.exec')
}
idea {
module {
testOutputDir = file('build/outputs/test-classes/debug')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment