JacocoTestReport not getting generated

525 views
Skip to first unread message

Chinmay Mujumdar

unread,
Jul 28, 2022, 9:49:19 AM7/28/22
to JaCoCo and EclEmma Users
```
apply plugin: 'jacoco'

ext {
coverageExclusions = [
'**/*Activity*.*',
'**/*Fragment*.*',
'**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
]
}

jacoco {
toolVersion = '0.8.6'
reportsDir = file("$buildDir/reports")
}

tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
// https://github.com/gradle/gradle/issues/5184#issuecomment-457865951
jacoco.excludes = ['jdk.internal.*']
}

tasks.withType(Test) {
finalizedBy jacocoTestReport // report is always generated after tests run
}

task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
group = "Reporting"
description = "Generate Jacoco coverage reports for Debug build"

reports {
xml.enabled = true
xml.outputLocation.set(new File("${project.buildDir}/reports/jacoco/jacocoTestReport/jacocoTestReport.xml"))
html.enabled = true
}

def debugTree = fileTree(dir: "${buildDir}/intermediates/javac/debug/classes", excludes: coverageExclusions)
def mainSrc = "/src/main/java"

additionalSourceDirs.from = files(mainSrc)
sourceDirectories.from = files([mainSrc])
classDirectories.from = files([debugTree])

executionData.from = files("$buildDir/jacoco/testDebugUnitTest.exec")
}
```
Above is my jacoco.gradle file. I have searched alot for this but not getting any solution. Jacoco is not able to generate the jacocoTestReport folder and .xml file because of which sonarqube coverage i am getting is 0%. What wrong i am doing in this ?
Reply all
Reply to author
Forward
0 new messages