Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jacoco coverage reported as 0.0% on first run #7

Open
ardevd opened this issue Mar 23, 2018 · 6 comments
Open

Jacoco coverage reported as 0.0% on first run #7

ardevd opened this issue Mar 23, 2018 · 6 comments

Comments

@ardevd
Copy link

ardevd commented Mar 23, 2018

It seems like the console reported always prints out 0.0% coverage on the first run in a clean environment.

Steps to produce:

  1. Delete any previous reports directory.
  2. Run ./gradlew jacocoTestReport
  3. Notice how the coverage summary says 0.0% coverage.
  4. Run ./gradlew jacocoTestReport again
  5. 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.

@louth
Copy link

louth commented Apr 30, 2018

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.

@StFS
Copy link

StFS commented Oct 22, 2019

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.

@StFS
Copy link

StFS commented Oct 23, 2019

What actually fixed it for me was to add the following line to my build.gradle:

reportCoverage.dependsOn jacocoTestReport

@leonardotc
Copy link

leonardotc commented Mar 3, 2020

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.

@abedurftig
Copy link

@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.

@ardevd
Copy link
Author

ardevd commented Apr 21, 2020

Never figured out a way around the issue, no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants