Exclude the android folder from coverage

robolectric-error
Bradlee Speice 2014-11-17 15:41:09 -05:00
parent 9aa83bebe2
commit 5fbbf4ac13
1 changed files with 13 additions and 8 deletions

View File

@ -18,11 +18,16 @@ dependencies {
jacocoTestReport {
// Add Android sources/classes for coverage
// We can't use additionalClassDirs because of this:
// http://stackoverflow.com/a/17411305/1454178
// Additionally, for whatever reason, the exclude() call doesn't work
// inside doFirst {}, please don't move this.
/*
Alright, setting up Jacoco the right way is massively confusing.
Normally, you'd use something like additionalClassDirs to add the folders you need.
However, we want to exclude the android/ folder, and likely will need something else
in the future. In order to do this though, we need the doFirst block. See SO here:
http://stackoverflow.com/a/17411305/1454178
Additionally, to properly exclude, we need to run that code outside the doFirst block.
No clue why this is, but please don't change this without extensive testing.
*/
def jacocoExcludes = [
"android/**/*"
]
@ -33,12 +38,12 @@ jacocoTestReport {
classDirectories = firstVariant.javaCompile.outputs.files
}
// Back to your regularly scheduled Jacoco
dependsOn test
reports {
xml.enabled true
csv.enabled false
html.destination "${buildDir}/jacocoHtml"
}
}
// Code coverage should depend on the tests
project.jacocoTestReport.dependsOn project.test