'Maven test fail on terminal but passes in IntelliJ
My Spring Boot application uses TestNG and it has the surefire plugin. I am attempting to package it on the terminal but it keeps failing on the maven test step. If I run the maven package command on IntelliJ, all the maven steps run fine and pass.
I am only getting errors like below when it is attempting to mvn test
on the terminal/command line. What could it be? I thought it was a Mockito dependency issue but even after added it in my pom.xml nothing changed.
You can learn about inline mocks and their limitations under item #39 of the Mockito class javadoc.
Underlying exception : org.mockito.exceptions.base.MockitoException: Could not modify all classes [class java.lang.Object, class org.fluentd.logger.FluentLogger]
at com.homedepot.appconfig.error.reporting.StackDriverErrorReporterTest.reportError_WithHttpRequest_False(StackDriverErrorReporterTest.java:112)
Caused by: org.mockito.exceptions.base.MockitoException: Could not modify all classes [class java.lang.Object, class org.fluentd.logger.FluentLogger]
at com.homedepot.appconfig.error.reporting.StackDriverErrorReporterTest.reportError_WithHttpRequest_False(StackDriverErrorReporterTest.java:112)
Caused by: java.lang.IllegalStateException:
Byte Buddy could not instrument all classes within the mock's type hierarchy
This problem should never occur for javac-compiled classes. This problem has been observed for classes that are:
- Compiled by older versions of scalac
- Classes that are part of the Android distribution
at com.homedepot.appconfig.error.reporting.StackDriverErrorReporterTest.reportError_WithHttpRequest_False(StackDriverErrorReporterTest.java:112)
Caused by: java.lang.IllegalArgumentException
at com.homedepot.appconfig.error.reporting.StackDriverErrorReporterTest.reportError_WithHttpRequest_False(StackDriverErrorReporterTest.java:112)
Mockito cannot mock this class:```
Solution 1:[1]
Check the maven version and pom.xml file it is picking to run the test; this is my wild guess.
Solution 2:[2]
In my case maven-surefire-plugin
was missing in the <build>
section of the pom.xml
. Add the plugin:
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>your-version</version>
</plugin>
</plugins>
<!-- other plugins ...-->
</build>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | surya teja |
Solution 2 | IKo |