Jacoco remote code coverage for QE tests

49 views
Skip to first unread message

Sunil Joseph

unread,
Jan 21, 2025, 12:24:22 PMJan 21
to JaCoCo and EclEmma Users
Hi All,
I am trying to collect the code coverage report for our play-framework java application that is running on a docker and our QE tests that is running from a maven-exec-plugin on a ubuntu vm (where the play-framework docker is hosted).

The play-framework java app docker is build with the following JAVA options 
JAVA_OPTS="${JAVA_OPTS} -javaagent:/opt/docker/bin/jacoco-agent.jar=output=tcpserver,address=*,port=9003,excludes=router*"

The integration test coverage report is working fine and that is run from maven-failsafe-plugin. 

Thank you All.

Sunil Joseph

unread,
Jan 21, 2025, 1:41:58 PMJan 21
to JaCoCo and EclEmma Users
Let me clear about my question. Is it possible to collect the Jacoco code coverage report from maven-exec-plugin as in maven-failsafe-plugin?

Evgeny Mandrikov

unread,
Jan 22, 2025, 5:15:33 AMJan 22
to jac...@googlegroups.com
On Tue, Jan 21, 2025 at 7:41 PM Sunil Joseph <suni...@gmail.com> wrote:
Let me clear about my question. Is it possible to collect the Jacoco code coverage report from maven-exec-plugin as in maven-failsafe-plugin?

Yes.  Make sure that JVM with tests is using JaCoCo Java Agent:
of jacoco-maven-plugin
populate property argLine by configuration of JaCoCo Java Agent
this property is automatically picked up by maven-surefire-plugin (https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#argLine)
so that agent is used during execution of tests.

uses different property name, so most likely you just need to explicitly pass correct property to exec-maven-plugin.

Regards,
Evgeny

 
On Tuesday, January 21, 2025 at 11:24:22 AM UTC-6 Sunil Joseph wrote:
Hi All,
I am trying to collect the code coverage report for our play-framework java application that is running on a docker and our QE tests that is running from a maven-exec-plugin on a ubuntu vm (where the play-framework docker is hosted).

The play-framework java app docker is build with the following JAVA options 
JAVA_OPTS="${JAVA_OPTS} -javaagent:/opt/docker/bin/jacoco-agent.jar=output=tcpserver,address=*,port=9003,excludes=router*"

The integration test coverage report is working fine and that is run from maven-failsafe-plugin. 

Thank you All.

--
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 visit https://groups.google.com/d/msgid/jacoco/222ba60c-84e7-4ecb-bbff-c17ec7e2000fn%40googlegroups.com.

Sunil Joseph

unread,
Jan 24, 2025, 12:26:53 AMJan 24
to JaCoCo and EclEmma Users
Thanks for the quick response.
My exec plugin is as follows. How do I pass the configured argLine property for Jacoco?
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>Start QE Tests</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<skip>${skipQeTests}</skip>
<executable>docker-compose</executable>
<commandlineArgs>up qe-tcases</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Sunil Joseph

unread,
Feb 10, 2025, 8:51:49 AMFeb 10
to JaCoCo and EclEmma Users
Do we need prepare-agent in my case? The agent is already set as JAVE options when I build play-framework docker image.

Sunil Joseph

unread,
Mar 4, 2025, 11:15:12 AMMar 4
to JaCoCo and EclEmma Users
I solved my issue as follows.

If we configured Jacoco agent with JAVA_OPTS as above and the application is running in a docker container then we can get the coverage data(file with .exec extension) from outside of the container by using Jacoco maven dump goal.
We don't need the Jacoco prepare-agent maven goal in this case. But we need to provide the classes under test in maven target/classes folder. When I provided the classes under test in a jar file the exclusion of classes for the report genration wasn't working but when I extracted the jar file the class exclusion started working.

Thanks.
Reply all
Reply to author
Forward
0 new messages