JaCoCo configuration when sources and tests classes are in different modules

I have a multi-module project with Gradle(2.2) + JaCoCo + Sonar. I’m using the


plugin, and when I execute the tests, I can see in each module the test report under build/jacoco/jacoco.exec. So far so good.

The problem is, I have some tests in module A that are testing classes from other module B, and so that JaCoCo is identifying that classes from module B with 0% code-coverage. I know this is not a good practice but it has to be done like that.

Example of the structure:

moduleA ----src --------java ------------Foo --------test moduleB ----src --------java --------test ------------TestFoo

Then JaCoCo will show the class Foo with 0% coverage. I have tried merging the results from all modules but I get the same result but in one single file, so this is not what I’m looking for. Is there any option to include sources from other module when executing the JaCoCo report?


Any ideas please?

I think you need to  to add the Foo class to the jacoco configuration by using

test {
    jacoco.includes << “*Foo