JaCoCo configuration when sources and tests classes are in different modules
Asked Answered
M

1

10

I have a multi-module project with Gradle(2.2) + JaCoCo + Sonar. I'm using the sonar-runner 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?

Thanks.

Millerite answered 14/11, 2014 at 15:41 Comment(0)
E
0

each module need its own tests. Jacoco build each jacoco.exec module after module and cannot go back to a previous one. So you have to set a TestFoo in moduleA.

Ernestoernestus answered 7/4, 2017 at 14:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.