After upgrading to Gradle version 5.5.1 my tests started failing on Jenkins with the following errors:
- Error while instrumenting class
- Class is already instrumented
My Jacoco Version is 0.8.4 and I also use PowerMock 1.6.5 version.
Here is my Jacoco configuration:
// Jacoco config
apply plugin: 'jacoco'
jacoco {
toolVersion = project.ext.jacocoToolVersion
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
def coverageSourceDirs = [
'src/main'
]
task jacocoTestReport(type: JacocoReport, dependsOn: 'testDebugUnitTest') {
group = "Reporting"
description = "Generate Jacoco coverage reports"
classDirectories = fileTree(
dir: 'build/intermediates/classes',
excludes: ['**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/BuildConfig.*',
'**/Manifest*.*']
)
additionalSourceDirs = files(coverageSourceDirs)
sourceDirectories = files(coverageSourceDirs)
executionData = files('build/jacoco/testDebugUnitTest.exec')
reports {
xml.enabled = true
html.enabled = true
}
}