No coverage on code which is in different module than the tests

37 views
Skip to first unread message

Jakub Kubena

unread,
Jan 19, 2023, 10:20:53 AM1/19/23
to JaCoCo and EclEmma Users
Hello,
I have a 2 module project. Code is in both of the modules, but tests for both modules are only in the 2nd one. This results in code from the 1st module, having 0 coverage. Is it possible to cover code with tests which are not in the same module? I have tried all the guides I could find, tried to use a 3rd module just for report aggregation, but this only works if I have code and tests together in their respective modules. which I cant have because my tests arent module specific. Is it just a case of incorrect configuration or am I trying to do the impossible here?

Marc Hoffmann

unread,
Jan 19, 2023, 10:45:12 AM1/19/23
to JaCoCo and EclEmma Users
Hi,

assuing you’re talking about a maven build, right?

This can be solved with a third module and the report-aggregate goal (https://www.jacoco.org/jacoco/trunk/doc/report-aggregate-mojo.html). With this goal the exec data of all dependent modules are combined, so test can be in different modules.

Regards,
-marc

On 19. Jan 2023, at 16:20, Jakub Kubena <jakub...@gmail.com> wrote:

Hello,
I have a 2 module project. Code is in both of the modules, but tests for both modules are only in the 2nd one. This results in code from the 1st module, having 0 coverage. Is it possible to cover code with tests which are not in the same module? I have tried all the guides I could find, tried to use a 3rd module just for report aggregation, but this only works if I have code and tests together in their respective modules. which I cant have because my tests arent module specific. Is it just a case of incorrect configuration or am I trying to do the impossible here?

--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/7d498057-4565-4195-a75d-1a656390a320n%40googlegroups.com.

Jakub Kubena

unread,
Jan 19, 2023, 10:50:12 AM1/19/23
to JaCoCo and EclEmma Users
Hi,
thank you very much for your response.

Yes, it is a maven build. I am already using the 3rd module, which is specificaly for report aggregation, in which Im using the goal you are mentioning. However, this still leads to 0 coverage on code which is outside of the module containing all the tests. Are you sure this should be also working when I have tests and source code in different modules?

Marc Hoffmann

unread,
Jan 19, 2023, 10:51:17 AM1/19/23
to JaCoCo and EclEmma Users
This is what the module is designed for.

Note: The coverage report is generated in that 3rd module!

Jakub Kubena

unread,
Jan 19, 2023, 11:23:57 AM1/19/23
to jac...@googlegroups.com
When I follow this guide, I manage to get it working if I have tests in their respective modules. If I move all the tests to a single module. then the one module not containing tests won't be covered. I would be grateful if you could point out what is incorrect in this guide. I basically copy pasted it.

Then I tried to adjust it a bit more into my use case and with that code I created a stackoverflow question. This again still only works with tests in their respective modules, but there are examples of my code.

Again, if you are willing, I would be grateful for pointing out any incorrect implementation. Or if you could provide some better guide or documentation.

You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/71gCTGiBG_c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/4C2CEDC2-BE61-4EA7-82B7-8E9793B4C991%40mountainminds.com.
Reply all
Reply to author
Forward
0 new messages