我的测试文件中有以下声明,当我运行测试时,这两行中的第一行失败。
@BeforeAll
public static void beforeAll() {
loggerFactoryMockedStatic = mockStatic(LoggerFactory.class);
loggerFactoryMockedStatic.when(() -> LoggerFactory.getLogger(PipelineExecutionService.class))
.thenReturn(logger);
}
我得到的错误是这样的:
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.
所以,我改变了我的 POM 文件的一部分
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
到
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
但是,运行测试后我仍然收到此错误。 知道为什么会这样吗?