我正在将 JUnit 升级到版本 5,当我运行 JUnit 5 时出现此错误
我在我的pom中使用
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
org.powermock.api.mockito.ClassNotPreparedException:
[Ljava.lang.Object;@723ca036 com.xxxxxx.MyClass 类未准备好 用于测试。
我正在使用
@RunWith(JUnitPlatform.class)
作为我的课堂测试符号
我的代码是
PowerMockito.mockStatic(MyClass.class);
when(MyClass.get(anyString()))
.thenReturn(mock);
您必须使用ExtendWith。在junit 5中,注释被@RunWith更改为
@ExtendWith(JUnitPlatform.class)