Tanvi Garg
Tanvi Garg

Reputation: 316

JacocoTestReport Skipped

I have a gradle project which is configured with Jacoco for the code coverage.But I don't see any exec file generated while executing the jacocoTestReport task. For the reference, my unit tests are successfully executing,I have the index.html file which is generated after executing unit tests.

Below is my jacoco configuration from build.gradle file.

jacocoTestReport {

outputs.upToDateWhen { false }

group = "Reporting"

//classDirectories = fileTree(dir: "build/classes/test")

//additionalSourceDirs = files(srcRoot)
//sourceDirectories = files(srcRoot)
//executionData = files("${allTestResults}/jacoco/jacocoTest.exec")

reports {
    xml.enabled true
    csv.enabled false
    html.destination "${testResults}/coverage"
}
}

jacocoTestReport.dependsOn test

And below is the screenshot for the index.html

enter image description here

Under my task Test,there's some jacoco configurations,below is the snippet :

jacoco {
    append = false
    destinationFile = file("$testResults/jacoco/jacocoTest.exec")
    classDumpFile = file("$testResults/jacoco/classpathdumps")
}

Can anyone suggest me what I'm missing?

Upvotes: 4

Views: 3667

Answers (1)

M. Amer
M. Amer

Reputation: 1136

I had a similar issue , exec file is not generated as well.

I found that the jacocoTestReport was simply "skipped".

It got fixed by adding :

test {
  useJUnitPlatform()
}

That's because I'm using Junit5 with spring boot 2.X

I'm adding this answers here , to help others who keep searching for hours without being able to find a direct answer for this issue just like myself ...

Upvotes: 1

Related Questions