【发布时间】:2022-01-21 07:02:30
【问题描述】:
我在测试中使用了“MockedStatic”,但是通过执行方法出现了这个错误。
org.mockito.exceptions.base.MockitoException:
The used MockMaker SubclassByteBuddyMockMaker does not support the creation of static mocks
Mockito's inline mock maker supports static mocks based on the Instrumentation API.
You can simply enable this mock mode, by placing the 'mockito-inline' artifact where you are currently using 'mockito-core'.
Note that Mockito's inline mock maker is not supported on Android.
我已插入“mockito-inline”依赖项,但 Maven 似乎无法解决它。此错误的文字在文章中。
我正在使用 Java 11、Junit 5。
pom.xml:
...<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>3.8.0</version>
<scope>test</scope>
</dependency>...
【问题讨论】:
-
该工件存在:mvnrepository.com/artifact/org.mockito/mockito-inline/3.8.0 maven 输出中的更多详细信息可能会有所帮助。
-
它们是两个不同的消息。您发布的内容是关于您正在运行测试,这意味着您的设置错误?您帖子的标题是错误的,因为如果没有找到依赖项,那么在编译和运行您的测试之前就会出现错误......