如何在JUnit5中模拟静态方法
我正在将JUnit升级到版本5,当我运行JUnit5时,出现了这个错误 我正在使用我的pom如何在JUnit5中模拟静态方法,junit,junit5,Junit,Junit5,我正在将JUnit升级到版本5,当我运行JUnit5时,出现了这个错误 我正在使用我的pom <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> </dependency> <dependency> <groupId>or
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
您必须使用ExtendWith。在JUnit5中,注释将@RunWith更改为 @ExtendWith(JUnitPlatform.class) 可能存在的副本
PowerMockito.mockStatic(MyClass.class);
when(MyClass.get(anyString()))
.thenReturn(mock);