Groups
Groups

Jacoco reports using surefire:test

587 views
Skip to first unread message

tejaswi pinnaka

unread,
Jun 30, 2023, 2:28:36 PM6/30/23
to JaCoCo and EclEmma Users
Can jacoco reports be created using mvn initialize surefire:test, because they generated in my case but the coverage shows 0 percent, this happens when running the build remotely. If I run the build on my local using mvn clean test, the reports are generated accurately.

Thanks

Marc Hoffmann

unread,
Jul 2, 2023, 2:41:26 AM7/2/23
to JaCoCo and EclEmma Users
Hi,

so what is the exact difference when you the build “remotely”? Maybe comparing both Maven log files gives you an idea.

Regards,
-marc


On 30. Jun 2023, at 20:28, tejaswi pinnaka <tejaswi...@gmail.com> wrote:

Can jacoco reports be created using mvn initialize surefire:test, because they generated in my case but the coverage shows 0 percent, this happens when running the build remotely. If I run the build on my local using mvn clean test, the reports are generated accurately.

Thanks

--
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/f96dfcb6-e47d-4e32-8671-bb7e19579f67n%40googlegroups.com.

Message has been deleted
Message has been deleted

Marc Hoffmann

unread,
Jul 7, 2023, 6:38:53 AM7/7/23
to JaCoCo and EclEmma Users
Hi, 

> on the remote server it is run using mvn clean surefire:test

If you don’t execute the prepare-agent goal of JaCoCo you will not get code coverage.

Regards,
-marc


On 5. Jul 2023, at 22:48, 'Tejaswi Pinnaka' via JaCoCo and EclEmma Users <jac...@googlegroups.com> wrote:

Hi, 

The difference between my local and remote build is that my local runs with mvn clean test command and the jacoco reports are generated accurately in this scenario. Whereas, on the remote server it is run using mvn clean surefire:test and in this scenario the jacoco aggregate is showing 0 percent coverage. So, I was wondering whether surefire:test wouldn't generate accurate jacoco reports.

Thanks and regards,
Tejaswi

Message has been deleted

tejaswi pinnaka

unread,
Jul 10, 2023, 8:30:26 AM7/10/23
to JaCoCo and EclEmma Users
Hi Marc,

Thank you for the reply.

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.10</version>
<executions>
<execution>
<id>prepare-unit-tests</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${basedir}/target/jacoco.exec</destFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>report-aggregate</id>
<phase>test</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
<execution>
<id>merge-results</id>
<phase>test</phase>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<directory>${code.coverage.project.folder}</directory>
<includes>
<include>**/jacoco.exec</include>
</includes>
</fileSet>
</fileSets>
<destFile>${code.coverage.overall.data.folder}/aggregate.exec</destFile>
</configuration>
</execution>
</executions>
</plugin>
This is the pom. Report is generated successfully when I use the command mvn clean test but it is generated with zero percentage when I use mvn initialize surefire:test. Does the report generation not work successfully with mvn surefire:test?

Evgeny Mandrikov

unread,
Jul 10, 2023, 8:39:04 AM7/10/23
to JaCoCo and EclEmma Users
You bind execution of jacoco goal "report-aggregate" to phase "test",
phase "test" is executed when you run "mvn clean test",
however when you run "mvn initialize surefire:test" you explicitly instruct maven to execute only goal "surefire:test" and not the entire "test" phase and hence jacoco goal "report-aggregate" won't be executed.

tejaswi pinnaka

unread,
Aug 3, 2023, 1:49:08 PM8/3/23
to JaCoCo and EclEmma Users
Hi Evgeny,

Thank you so much for your reply. I have integrated surefire:test and jacoco:report-aggregate into a single command like this: mvn initialize surefire:test jacoco:report-aggregate. This couldn't generate the reports too. Is there anyway I can implement any other parts of test phase along with surefire:test to get the jacoco report aggregation working?

Thanks and regards,
Tejaswi

Reply all
Reply to author
Forward
0 new messages
Search
Clear search
Close search
Google apps
Main menu