Permalink
Switch branches/tags
Nothing to show
Find file Copy path
cc8c1ab Nov 25, 2016
0 contributors

Users who have contributed to this file

55 lines (50 sloc) 1.91 KB
apply plugin: 'jacoco'
ext {
coverageSourceDirs = 'src/test/java'
}
jacoco {
toolVersion = "0.7.5.201505241946"
reportsDir = file("$buildDir/reports")
}
task jacocoTestReport(type:JacocoReport, dependsOn: "testDebugUnitTest") {
group = "Reporting"
description = "Generate Jacoco coverage reports for Debug build"
classDirectories = fileTree(
dir: "$buildDir/intermediates/classes/debug",
excludes: ['**/R.class',
'**/R$*.class',
'**/*$ViewBinder*.*',
'**/*$InjectAdapter*.*',
'**/*Injector*.*',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Test*.*',
'**/*Activity*.*',
'**/CiMattersApplication*.*',
'android/**/*.*']
)
if (project.hasProperty("teamcity")) {
println '##teamcity[jacocoReport dataPath=\'app/build/jacoco/testDebugUnitTest.exec\' includes=\'com.vgaidarji.cimatters.*\' excludes=\'com.vgaidarji.cimatters.test.* **/*R*.* **/*Injector*.* **/*Activity*.* .*R .*CiMattersApplication .*BuildConfig .*Activity .*Test \']'
}
reports {
xml.enabled = true
html.enabled = true
}
additionalSourceDirs = files(coverageSourceDirs)
sourceDirectories = files(coverageSourceDirs)
executionData = files("$buildDir/jacoco/testDebugUnitTest.exec")
// Bit hacky but fixes https://code.google.com/p/android/issues/detail?id=69174.
// We iterate through the compiled .class tree and rename $$ to $.
doFirst {
new File("$buildDir/intermediates/classes/").eachFileRecurse { file ->
if (file.name.contains('$$')) {
file.renameTo(file.path.replace('$$', '$'))
}
}
}
}
tasks.withType(Test) {
testLogging {
events "passed", "skipped", "failed"
}
}