I have a Gradle based Java/Groovy project that contains several subprojects. Let's say that subproject-a has a source class, subproject-b has a test class that tests the code under subproject-a. I am unable to figure out how to configure Clover to count the test coverage that subproject-b provides to subproject-a. I created an example project which shows a simple example of my issue. Combining each subproject's clover results does work fine, but the only code coverage that gets counted is when the source and test are in the same project.
I realize that the gradle-clover-plugin is an open source project, but is what I'm trying to do possible in Maven or Ant? I'm sure with Ant I could just build all the subprojects as one big single project and that would work, but I'd like to maintain my multi-project setup with project level dependencies.
I hope this makes sense. Thanks!
I ran 'gradle cloverGenerateReport --debug'.
In the report I've found that the Dog class (from subproject-a) called from DogServiceTest (from subproject-b) has no coverage. I assume that this is a problem you're writing about.
In the build log I've found the following:
14:50:47.828 [DEBUG] [org.gradle.process.internal.DefaultWorkerProcessFactory] Creating Gradle Worker 3 14:50:47.828 [DEBUG] [org.gradle.process.internal.DefaultWorkerProcessFactory] Using application classpath [ <workspace>\subproject-b\build\classes\test, <workspace>\subproject-b\build\resources\test, <workspace>\subproject-b\build\classes\main, <workspace>\subproject-b\build\resources\main, <home>\.gradle\caches\modules-2\files-2.1\org.codehaus.groovy\groovy-all\2.2.2\7a917c8329fe11445de19c2ca28fd2ca586830da\groovy-all-2.2.2.jar, <workspace>\subproject-a\build\libs\subproject-a.jar, <<<<< USING subproject-a.jar <home>\.gradle\caches\modules-2\files-2.1\junit\junit\4.11\4e031bb61df09069aeb2bffb4019e7a5034a4ee0\junit-4.11.jar, <home>\.gradle\caches\modules-2\files-2.1\org.hamcrest\hamcrest-core\1.3\42a25dc3219429f0e5d060061f71acb49bf010a0\hamcrest-core-1.3.jar, <home>\.gradle\caches\modules-2\files-2.1\com.cenqua.clover\clover\3.2.0\e09feecf14644d92003ab037c30e483cf86b3e82\clover-3.2.0.jar] 14:50:48.528 [DEBUG] [TestEventLogger] Gradle Worker 3 STARTED 14:50:48.533 [QUIET] [system.out] 14:50:48.532 [DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor] Executing test class com.example.DogServiceTest ... 14:50:49.033 [DEBUG] [TestEventLogger] com.example.DogServiceTest > makeDogSpeakTest STANDARD_OUT 14:50:49.033 [DEBUG] [TestEventLogger] Hello, my name is Mark
Please note that the subproject-b is using the ...\subproject-a\build\libs\subproject-a.jar and this JAR contains non-instrumented classes.
This is a reason why the Dog class has no coverage.
The JAR has non-instrumented classes, because the Gradle Clover Plugin has been written this way in order to be transparent and to avoid accidental deployment of instrumented code:
It means that, unfortunately, you cannot have a code coverage across modules, unless you'll hack the plugin and comment out this line:
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.Read more
As a Jira power user, I was at first doubtful that Trello could benefit my workflow. Jira already uses boards (ones you can customize!), so why would I even need to use Trello?! In this post you will...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs