Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Clover code coverage behavior differs between Maven and Gradle

Philippe Serre February 9, 2017

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
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 9, 2017

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

Philippe Serre February 9, 2017

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

Philippe Serre February 9, 2017

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events