gradle-console-reporter
gradle-console-reporter copied to clipboard
Jacoco coverage reported as 0.0% on first run
It seems like the console reported always prints out 0.0% coverage on the first run in a clean environment.
Steps to produce:
- Delete any previous reports directory.
- Run ./gradlew jacocoTestReport
- Notice how the coverage summary says 0.0% coverage.
- Run ./gradlew jacocoTestReport again
- The correct coverage summary is now printed.
This makes it impossible to use it for CI integration as the tests there will always be run in a clean environment.
I worked around this with
jacocoTestReport.dependsOn build
To be fair, it seems like more of a jacoco plugin issue than a problem with this plugin.
Unfortunately, your workaround did not solve this issue for me. So in my CI loop I'm actually running the gradle command twice. Fortunately, gradle manages to short-circuit the whole compiling and running of the tests so the build time impact is minimal, but the build config looks very ugly instead.
What actually fixed it for me was to add the following line to my build.gradle
:
reportCoverage.dependsOn jacocoTestReport
Fior me this worked:
test.finalizedBy jacocoTestReport
jacocoTestReport.finalizedBy reportCoverage
PS: I never used gradle before this so do not take this as the "best way" to do this nor anything. Hopefully, it will make someone's day easier.
@ardevd, do you still have this issue or did you find something that worked for you? I face the same issue in a multi-module Gradle project. Thanks.
Never figured out a way around the issue, no.