Gradle project with subprojects, what is coverage reporting?
We have a Gradle project with multiple subprojects. When I use Execute Gradle Task ...
> gradle :entities:test
And run this with coverage, I get 100% coverage on my entity class. Yay! But, when I run
> gradle test
And run this with coverage, I get 100% class, 85% method, 76% line coverage ... ??
Following principle of least surprise, I guess I would expect the coverage report to show me the union of coverages collected from all subprojects. As it stands ... I'm not sure what it's actually showing me ... the coverage from the last subproject executed? I'm not sure what value that would have ...
Any guidance appreciated, thanks!
p.s. we have the jacoco plugin in Gradle for our CI reporting, but I haven't found any way to integrate this with Intellij - you can use the built-in jacoco, but that doesn't produce anything different and doesn't leverage our jacoco gradle tasks.
Please sign in to leave a comment.
Please check your run configuration. What packages are defined here?
https://i.imgur.com/fO24sob.png
> I haven't found any way to integrate this with Intellij
Here is the feature request: https://youtrack.jetbrains.com/issue/IDEA-100744
I don't see anything there - do I need to add these manually or should IntelliJ find these packages? It recognizes the packages present in the subprojects if I navigate around in the Project Structure, so ...
When I manually add the base package, e.g. 'gov', that everything else is a subpackage to, I get different results ... now running
> gradle test
with Coverage gives me 50% Class, 75% Method, and 71% Line coverage on the package for our entities.
So, if I create a merged jacoco execution data file, using inspiration from the jacocoMergeTestData task in https://github.com/gradle/gradle/issues/5898#issuecomment-494230499, and then add that coverage data using the Run | Show Code Coverage Data | + dialog, pointing at `testCombo.exec` - then navigate through those results, I *do* see the expected 100% coverage for the entities package ... if that helps.
After doing that, if I run the root project level task that runs all test & updates that `testCombo.exec` coverage data, it appears as though the Coverage panel updates and displays the new results ... so, I think that might be all I need until Intellij automagically does what the merge task is doing and wires up the coverage data from the various *.exec files itself?