Reputation: 16833
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 ?
Upvotes: 1
Views: 457
Reputation: 27984
Now that we've got the fun out of the way and ruled out JaCoCo, I think you'll need to provide clover with additional source dirs
Eg:
apply plugin: 'com.bmuschko.clover'
evaluationDependsOn ':someOtherProject'
clover {
additionalSourceDirs = project(':someOtherProject').sourceSets.main.allSource.srcDirs
}
Upvotes: 2