Clover code coverage behavior differs between Maven and Gradle

I am migrating a Maven Project to Gradle and I have an issue with my code coverage plugin : Clover. I have an unexplained behavior about coverage computation. Let's take a simple example :

// ProjectA
class A
{
    void method1()
    {
        // Some stuff
        // This method is covered by a unit test in ProjectA
    }
    
    void method2()
    {
        // Some stuff
        // This method is not covered by any unit test in ProjectA
    }
}
// ProjectB
class B
{
    void method3()
    {
        new A().method2();
        // Some stuff
        // This method is covered by a unit test in ProjectB
    }
}

I have 2 different project : ProjectA and ProjectB. ProjectB depends on ProjectA.

ProjectA contains a class named A. method1 from A is covered by a unit test contained in ProjectA. method2 is not covered by any test contained in ProjectA.

ProjectB contains a class named B. method3 from B is covered by a unit test contained in ProjectB. method3 calls method2 from class A in ProjectA.

The fact :

With Maven and Clover (official plugin), method2 is considered covered as it's call from a method (method3) covered by a unit test, even if the test is in a different project. With Gradle and Clover (unofficial plugin), method2 is considered uncovered as there is no dedicated test in ProjectA.

The configuration is kind of basic, no major difference between Maven and Gradle Clover plugin.

My questions :

What is the normal / default behavior of Clover ? Can this behavior be set through configuration ? Or is this some kind of bug in the Gradle Clover plugin ?

 

 

1 answer

0 vote

I guess that in your Gradle build two clover.db databases have been created: one for ProjectA and one for ProjectB. Am I correct?

If yes then did you merge these two databases into one for reporting?

If yes then did you use the "aggregateDatabases" or the "aggregateReports" task? 

 

https://github.com/bmuschko/gradle-clover-plugin/blob/master/src/main/groovy/com/bmuschko/gradle/clover/AggregateDatabasesTask.groovy

https://github.com/bmuschko/gradle-clover-plugin/blob/master/src/main/groovy/com/bmuschko/gradle/clover/AggregateReportsTask.groovy

I used the task cloverAggregateReports which pretty covers it all as I am in multi project architecture.

My build.gradle file is on top of projectA and ProjectB

Suggest an answer

Log in or Join to answer
Community showcase
Emilee Spencer
Published yesterday in Marketplace Apps

Marketplace Spotlight: DeepAffects

Hello Atlassian Community! My name is Emilee, and I’m a Product Marketing Manager for the Marketplace team. Starting with this post, I'm kicking off a monthly series of Spotlights to highlight Ma...

47 views 0 3
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot