我的Spring Boot应用程序使用TestNG,并且具有surefire插件。我试图将其打包在终端上,但在maven测试步骤中始终失败。如果我在IntelliJ上运行maven package命令,则所有maven步骤都可以正常运行并通过。
在终端/命令行上尝试mvn test
时,只会出现如下错误。会是什么呢?我以为这是Mockito依赖项问题,但是即使将其添加到pom.xml中也没有改变。
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:```
答案 0 :(得分:0)
检查运行测试所选择的Maven版本和pom.xml文件;这是我的疯狂猜测。