question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not working with org.jacoco:jacoco-maven-plugin

See original GitHub issue

Hi, I just updated a large project from java 11 to 17 and introduced log-captor for unit testing.

Now all my test are fine in the IDE, but when running them in the CI/CD pipeline on the server or locally with “./mvnw org.jacoco:jacoco-maven-plugin:prepare-agent test -Dmaven.test.failure=true”

I face failing tests depending on the environment these are different test. Always the log-captor seems to miss some logging.

This is how the pom looks like:

 <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.22.2</version>
                    <configuration>
                        <excludes>
                            <exclude>**/*IntegrationTest.java</exclude>
                            <exclude>**/*PerformanceTest.java</exclude>
                        </excludes>
                        <classpathDependencyExcludes>
                            <classpathDependencyExclude>org.apache.logging.log4j:log4j-slf4j-impl</classpathDependencyExclude>
                        </classpathDependencyExcludes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.22.2</version>
                    <configuration>
                        <classpathDependencyExcludes>
                            <classpathDependencyExclude>org.apache.logging.log4j:log4j-slf4j-impl</classpathDependencyExclude>
                        </classpathDependencyExcludes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <configuration>
                        <excludes>
                            <exclude>**/*IntegrationTest.*</exclude>
                            <exclude>**/*PerformanceTest.*</exclude>
                        </excludes>
                    </configuration>
                </plugin>

Any ideas what might go wrong?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
recumbentseekercommented, Feb 21, 2022

Thanks for your help, we need the snapshot package.

I’ll try to test logging with a custom appender.

0reactions
Hakky54commented, Feb 21, 2022

I just found out that when I used that library, json-snapshot, none of my tests got executed. I could not replicate on my side that LogCaptor was causing issues, but maybe my setup is not identical to yours.

You could also try to use https://github.com/Hakky54/console-captor which just captures the console output. In that way you don’t need a custom appender or custom logic to capture logs from a logging framework.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maven JaCoCo plugin error - Stack Overflow
I faced the same problem and fixed by using below command in place of jacoco:report - mvn -X org.jacoco:jacoco-maven-plugin:report.
Read more >
artifacts not resolved: org.jacoco:org.jacoco.build:jar:0.6 ...
correctly. I'm trying to implement jacoco coverage reports in a multi-project maven build and I am running into the following error when I...
Read more >
Could not find artifact org.jacoco:jacoco-maven-plugin:pom ...
When trying to build the package: mvn clean package [INFO] Scanning for projects.
Read more >
Untitled
4.0.0 org.jacoco org.jacoco.build 0.8.6 pom JaCoCo JaCoCo - Java Code ... GitHub https://github.com/jacoco/jacoco/issues sonatype-nexus-staging Nexus ...
Read more >
Jacoco in Maven Projects - Personal Programming Notes
There are two options to fix that error. The easiest way is to specify the groupId and artifactId parameters of the plugin explicitly....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found