How to configure jacoco for integration tests written in jersey test framework

813 views
Skip to first unread message

yours...@gmail.com

unread,
May 30, 2016, 7:09:38 AM5/30/16
to JaCoCo and EclEmma Users
I am trying to integrate jacoco. I successfully integrated it with unit tests using the following configuration

<plugin>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
<goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
<goals>
</execution>
</executions>
</plugin>

I replaced prepare-agent goal with prepare-agent-integration but i cant see any reports.

I see a message saying skipping jacoco execution due to missing classes directory.

My integration tests are in a seperate module.

Can anyone please help me how to configure jacoco for my integration tests?

I am using jersey-test-framework-grizzly2 1.12 from com.sun.jersey.jersey-test-framework

Thanuku Krishna Chaitanya

unread,
May 30, 2016, 8:35:26 AM5/30/16
to JaCoCo and EclEmma Users
Meanwhile i added maven copy resources plugin to copy the required class files from other module to target/classes and jacoco is now generating the report. I dont know how far this hack will work.

On the other hand the report does not show the source code.

Marc R. Hoffmann

unread,
May 30, 2016, 11:02:17 AM5/30/16
to jac...@googlegroups.com
Hi,

currently JaCoCo Maven plug-in does not support this setup out-of-the-box.

There will be a new goal report-aggregate which support exactly this
scenario (collection exec data and class/source files from multiple
projects): http://eclemma.org/jacoco/trunk/doc/report-aggregate-mojo.html

You may test this with 0.7.7-SNAPSHOT.

Regards,
-marc

Thanuku Krishna Chaitanya

unread,
May 31, 2016, 8:57:51 AM5/31/16
to JaCoCo and EclEmma Users
Thank you Marc. When will 0.7.7 be available in maven repository.

I am not able to download the plugin from the snapshot repo because i am behind a proxy. Authenticating to the proxy also does not work due to some unknown reasons.

I tried manually adding the jar and pom file to my local repo but still it does not work.

Evgeny Mandrikov

unread,
May 31, 2016, 4:59:01 PM5/31/16
to JaCoCo and EclEmma Users
Hi,

0.7.7 will be available in Maven central repository once it will be released, we are working on some remaining issues actually related to this new feature "report-aggregate" and plan to do release by the end of this week.

In the meantime you can build snapshot locally:
mvn clean install

Thanuku Krishna Chaitanya

unread,
Jun 7, 2016, 5:09:30 AM6/7/16
to JaCoCo and EclEmma Users
I am using the below configuration in my integration pom XML with 0.7.7 maven plugin

<plugin>
<executions>
<execution>
<goals>
<goal>prepare-agent-integration</goal>


<goals>
</execution>
<execution>
<id>report</id>

<goals>
<goal>report-aggregate</goal>
<goals>
</execution>
</executions>
</plugin>

The reports are still not getting generated.

Thanuku Krishna Chaitanya

unread,
Jun 7, 2016, 6:06:11 AM6/7/16
to JaCoCo and EclEmma Users
This is testing my patience.

Let me explain again. I have a project which has 20 modules in it. In one of the module we started writing integration tests.

We are using jersey test frameowork for the integration tests.

I added 0.7.7 jacoco maven plugin with report-aggregate goal as described above and i still dont see the reports.

I added the plugin with prepare-agent-integration and report-aggregate but the reports are not getting generated

Then changed it to use prepare-agent and report as the goals. The reports are generated but only for the classes current module.

I have another module which is completely for integration tests. It won't contain source files under main/java. When i run coverage for it, no reports are getting generated.

Can anyone please help me?

Mirko Friedenhagen

unread,
Jun 7, 2016, 9:44:09 AM6/7/16
to jac...@googlegroups.com

Hello Thanuku,

* you have to include all modules for which you want to have the aggregated report as dependencies of the aggregating module
* in your aggregating module you only need the report-aggregate execution.
* you have to bind the execution to a phase, e.g. verify.

See https://gitlab.com/mfriedenhagen/testlink-junit/blob/master/tljunit-jacoco-aggregate/pom.xml for an example.

Regards
Mirko
--
Sent from my mobile

--
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/b16fdd2e-0f29-4e19-afb4-315a728ae3fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thanuku Krishna Chaitanya

unread,
Jun 7, 2016, 10:59:05 AM6/7/16
to JaCoCo and EclEmma Users
Hi, i added all modules as dependencies. I binded it to verify phase and still it's not working. I tried changing the scope of all dependencies to compile as it is mentioned in the documentation. But no luck

Thanuku Krishna Chaitanya

unread,
Jun 7, 2016, 11:18:59 AM6/7/16
to JaCoCo and EclEmma Users
Actually I see an empty report when I open the html file under jacoco-aggregate

Mirko Friedenhagen

unread,
Jun 7, 2016, 12:37:28 PM6/7/16
to jac...@googlegroups.com

Hello Thanuku,

I have seen this as well, when I had  scope for a dependency. Just to be sure: the single module reports are created correctly? Aggregate only collects previously created jacoco.exec files.

Regards
Mirko
--
Sent from my mobile

Am 07.06.2016 17:19 schrieb "Thanuku Krishna Chaitanya" <yours...@gmail.com>:
Actually I see an empty report when I open the html file under jacoco-aggregate

--
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.
Message has been deleted

Thanuku Krishna Chaitanya

unread,
Jun 7, 2016, 2:11:54 PM6/7/16
to JaCoCo and EclEmma Users
I think the plugin is working fine. I created a sample project at home with three modules including a module for integration tests and i can see the report getting generated. But here i did not use Jersey Test framework. I am using junit only.

The code is available at https://github.com/krishnaz3264/jacoco-beginner

I think the problem is with my dev environment at work. We are using java 1.6. Is this a problem?

Thanuku Krishna Chaitanya

unread,
Jun 7, 2016, 2:31:22 PM6/7/16
to JaCoCo and EclEmma Users
I just observed that the plugin is generating an empty report if i build only the integration module. It is generating the full/actual report only if i build the root/parent project. I just tried with Jersey Test framework and the report is getting generated fine.

I think my work environment has some problem.

Thanks for the support guys.

Mirko Friedenhagen

unread,
Jun 7, 2016, 2:39:22 PM6/7/16
to jac...@googlegroups.com

Hello,

if you only execute one module the other modules will be pulled from your maven repository manager and the class files will probably be different. So this is to be expected.

Regards
Mirko
--
Sent from my mobile

--
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.

Evgeny Mandrikov

unread,
Jun 8, 2016, 5:13:32 AM6/8/16
to JaCoCo and EclEmma Users
exec files can be loaded only from projects within current reactor.


On Tuesday, June 7, 2016 at 8:39:22 PM UTC+2, Mirko Friedenhagen wrote:

Hello,

if you only execute one module the other modules will be pulled from your maven repository manager and the class files will probably be different. So this is to be expected.

Regards
Mirko
--
Sent from my mobile

Am 07.06.2016 20:31 schrieb "Thanuku Krishna Chaitanya" <yours...@gmail.com>:
I just observed that the plugin is generating an empty report if i build only the integration module. It is generating the full/actual report only if i build the root/parent project. I just tried with Jersey Test framework and the report is getting generated fine.

I think my work environment has some problem.

Thanks for the support guys.

--
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+unsubscribe@googlegroups.com.

Thanuku Krishna Chaitanya

unread,
Jun 8, 2016, 8:55:00 AM6/8/16
to JaCoCo and EclEmma Users
I just tried integrating jacoco 0.7.7 version and I observed a problem.

I have 20 modules out of which 19 modules contain junit test cases and one module is for the integration tests.

I added report-aggregate to the integration pom and it is generating a report which contains the unit test reports as well. So now I do not know how much of code is covered by my integration tests.

Can anyone suggest?

Evgeny Mandrikov

unread,
Jun 8, 2016, 9:08:29 AM6/8/16
to jac...@googlegroups.com
You can generate exec files with different names and specify "dataFileIncludes" for "report-aggregate" ( http://eclemma.org/jacoco/trunk/doc/report-aggregate-mojo.html#dataFileIncludes ) to include only exec file generated by integration tests.

Moreover - by default "prepare-agent" will generate "jacoco.exec" ( http://eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html#destFile ), while "prepare-agent-integration" will generate "jacoco-it.exec" ( http://eclemma.org/jacoco/trunk/doc/prepare-agent-integration-mojo.html#destFile ), so that you can specify "*-it.exec" as "dataFileIncludes".

--
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/wzEvbkrR-Aw/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/220e05c7-c90c-44e0-8adc-fdf01e09d3c5%40googlegroups.com.

Thanuku Krishna Chaitanya

unread,
Jun 8, 2016, 9:22:01 AM6/8/16
to JaCoCo and EclEmma Users
Hi thanks for the reply. I was also thinking about the same.
Message has been deleted

Thanuku Krishna Chaitanya

unread,
Jun 13, 2016, 7:29:25 AM6/13/16
to JaCoCo and EclEmma Users
I removed all unit test cases from my modules and their corresponding jacoco plugin entry from the pom file and builded my project. The integration tests ran fine and the report is generated.

Then i restored all my test cases and changed the dest file, data file and output directory locations. Then i ran the build and the integration report contained reports from unit tests also. I then tried excluding data file from my integration pom jacoco plugin. But still the integration report is containing unit report.

Can anyone please shed some light

Message has been deleted

Thanuku Krishna Chaitanya

unread,
Jun 13, 2016, 10:41:09 AM6/13/16
to JaCoCo and EclEmma Users
I just configured my unit exec file and reports locations to a directory outside the target directory and the integration report showed only coverage for integration tests.

I used <dataFile>${project.build.directory}/../.jacoco/jacoco-unit.exec</dataFile> and <destFile>${project.build.directory}/../.jacoco/jacoco-unit.exec</destFile> and <outputDirectory>${project.build.directory}/../.jacoco/site/unit<outputDirectory>

But i am not sure what problems will i face in future for moving the unit test reports to outside target directory.

I think there is some problem with the plugin while excluding the data files.

Evgeny Mandrikov

unread,
Jun 13, 2016, 1:48:18 PM6/13/16
to JaCoCo and EclEmma Users

I think there is some problem with the plugin while excluding the data files.

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