Merging code coverage through integration and unit tests.

899 views
Skip to first unread message

syash...@gmail.com

unread,
Sep 28, 2016, 4:23:36 AM9/28/16
to JaCoCo and EclEmma Users
Hi,

I came to know that we can generate aggregate-report that reports cross module code coverage for the maven plugin.

Please look into the below explanation for details about my question.

I have 2 Modules A and B.
If module A has Spring tests written which covers module A and 50% classes of module B.
Module B has unit tests which cover other 50% classes of module B.

Can we generate aggregate report for both modules A and B which shows coverage for module B as 100%?
Or does the latest version support in a way that the coverage is brought up for module A and 50% of module B only?

If Yes, please help with the configuration for the same.

Please let me know for any additional information.

Thank you.

Evgeny Mandrikov

unread,
Sep 28, 2016, 6:15:45 AM9/28/16
to JaCoCo and EclEmma Users, syash...@gmail.com
Hi,

Yes it is possible starting from version 0.7.7 , which introduced "report-aggregate" Maven mojo - see http://www.eclemma.org/jacoco/trunk/doc/report-aggregate-mojo.html
Also you can find an example in integration tests for JaCoCo Maven Plugin - see https://github.com/jacoco/jacoco/tree/v0.7.7/jacoco-maven-plugin.test/it/it-report-aggregate
And you can find other examples in internet, e.g. https://groups.google.com/d/msg/jacoco/mfRi97alxqs/63KqpEZKAQAJ

Hope this helps.

Best regards,
Evgeny

syash...@gmail.com

unread,
Sep 28, 2016, 11:18:08 AM9/28/16
to JaCoCo and EclEmma Users, syash...@gmail.com
Hi,

Thanks a lot for the quick reply. From the information you have provided I could create a sample multi-module project and was successfully able to replicate the same thing I was asking in the above request. But that was all using unit tests only.

Majority of the test cases we use are Spring tests (meaning they use @ContextConfiguration annotation) written for Controllers using testNG framework. When I run the build I see that this configuration is running only unit tests with @Test annotation. Spring tests which are triggered from testNG suite.xml file are not running. I have many such xml files which trigger the testControllers and test end-to-end functionality.

Please help me with the same on how to run these integration spring tests with jacoco.

Thanks
Yashwanth

Evgeny Mandrikov

unread,
Sep 28, 2016, 11:38:43 AM9/28/16
to JaCoCo and EclEmma Users, syash...@gmail.com
JaCoCo is agnostic to the way you run your tests.

If you can execute your tests without JaCoCo, then execution of tests with JaCoCo shouldn't differ.

Make sure that you generate reports on a correct stage, i.e. if your tests are execuetd as "integration tests" ( maven-failsafe-plugin or something like that ), then obviously report generation should be bound to the phase after it, e.g. "post-integration-test".

Please understand that we can't provide super precise help on hundreds of third-party frameworks and examples of the hundreds of cases. Obviously configuration might require some tuning, it is a bit unfair to believe that someone is gonna do all the homework.

syash...@gmail.com

unread,
Sep 28, 2016, 11:49:19 AM9/28/16
to JaCoCo and EclEmma Users, syash...@gmail.com
Thanks for your help. Apologies for bringing up such questions.

One request from the change log I see in 0.7.7.

"New parameters title and footer for Maven reporting goals allow customization of generated reports."

Does the above feature imply we can customise the report to check the covered lines instead of covered instructions?

Thanks.

Marc Hoffmann

unread,
Sep 28, 2016, 12:31:04 PM9/28/16
to jac...@googlegroups.com
No, this really means the header and footer of the report page, not the
table itself.

We have a PR in the pipe to make the table fully customizable:
https://github.com/jacoco/jacoco/pull/382

Regards,
-marc
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages