Reputation: 59
Expected Behavior
jacocoTestReport work
Current Behavior
jacocoTestReport SKIPPED
Context
I created a task whose type is Test, and jacocoTestReport depends on the task. When I ran the task, jacocoTestReport did not work and I got the following information
jacocoTestReport SKIPPED
I find if I use the task test
directly, jacocoTestReport worked fine. It makes me confused
the following code caused the above issue
plugins {
id 'java'
id 'jacoco'
}
repositories {
mavenCentral()
}
dependencies {
}
task myTest(type: Test) {
useTestNG()
useJUnitPlatform()
finalizedBy jacocoTestReport
reports {
junitXml.required = false
html.required = true
}
jacoco {
enabled = true
destinationFile = layout.buildDirectory.file("jacoco/${name}.exec").get().asFile
}
}
jacocoTestReport {
// tests are required to run before generating the report
dependsOn myTest
reports {
xml.required = false
csv.required = false
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
}
Steps to Reproduce
Your Environment
Gradle 7.1.1
Upvotes: 3
Views: 11321
Reputation: 988
I get the same issue. I post what I found here and hope it will be helpful for somebody with the same issue.
./gradlew clean build jacocoTestReport --i
> Task :lib:jacocoTestReport SKIPPED
Skipping task ':lib:jacocoTestReport' as task onlyIf is false.
:lib:jacocoTestReport (Thread[Execution worker for ':',5,main]) completed. Took 0.0 secs.
:lib:check (Thread[Execution worker for ':',5,main]) started.
root cause:
solution
test {
useJUnitPlatform()
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
xml.enabled false
csv.enabled false
html.enabled true
html.destination file("${buildDir}/jacocoHtml")
}
}
./gradlew test
references
Upvotes: 1
Reputation: 59
It is expected, not an issue. just because I use the jacocoTestReport in a wrong way
see https://github.com/gradle/gradle/issues/18271
Upvotes: 0