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 votes

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 Sign up to answer
Community showcase
Asked Thursday in Jira Ops

I'm John Allspaw, Ask Me Anything about incident analysis and postmortems

I'm John Allspaw, co-founder of   Adaptive Capacity Labs, where we help teams use their incidents to learn and improve. We bring research-driven methods and approaches to drive effective inciden...

443 views 2 5
View question

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