Clover Reporting for Multi Project Builds

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!

1 answer

1 accepted

0 votes
Accepted answer

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-a\build\libs\subproject-a.jar, <<<<< USING subproject-a.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 is really great, thanks for figuring this out for me. I'll talk with the maintainer of the clover plugin and see if we can do anything to better accommodate how this needs to work with clover. Looks like this should be supportable.

Indeed. Adding a switch for this should be trivial.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Jira

Make your Atlassian Cloud products more secure: our NEW admin security guide

Hey admins! I’m Dave, Principal Product Manager here at Atlassian working on our cloud platform and security products. Cloud security is a moving target. As you adopt more products, employees consta...

386 views 0 7
Read article

Atlassian User Groups

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!

Find my local user group

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

Groups near you