【发布时间】:2019-10-25 20:57:11
【问题描述】:
我的 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:```
【问题讨论】:
-
请点击此链接并编辑您的问题。 stackoverflow.com/help/minimal-reproducible-example
-
@DavidLe 你能解决这个问题吗?我遇到了完全相同的问题。我正在使用 jdk 11、junit juniper 5.3.2、mockito-junit-jupiter 2.24.0 和 mockito-core 2.24.4。当我在 IntelliJ 中运行时我的测试通过并在终端上失败并出现您遇到的错误。
标签: java maven intellij-idea