如何在Java JUnit中结合这两种RunWith?
@RunWith(SpringRunner.class) @Runwith(PowerMockRunner.class) 如何合并这两个注释。因为RunWith只支持单值。如果您使用的是JUnit 5,您就不能使用它,因为PowerMock还没有 对于JUnit4,使用如何在Java JUnit中结合这两种RunWith?,java,junit,powermock,Java,Junit,Powermock,@RunWith(SpringRunner.class) @Runwith(PowerMockRunner.class) 如何合并这两个注释。因为RunWith只支持单值。如果您使用的是JUnit 5,您就不能使用它,因为PowerMock还没有 对于JUnit4,使用@Runwith(PowerMockRunner.class)并使用@powermockrunnerregate注释添加SpringRunner.class。e、 g import org.springframework.test
@Runwith(PowerMockRunner.class)
并使用@powermockrunnerregate
注释添加SpringRunner.class
。e、 g
import org.springframework.test.context.junit4.SpringRunner;
导入org.powermock.modules.junit4.PowerMockRunner;
导入org.powermock.modules.junit4.powermockrunnerregate;
@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(SpringRunner.class)
@PrepareForTest(LogHelper.class)
@WebMvcTest(controllers=UserController.class)
公共类UserControllerTest{
@自动连线
私有MockMvc-MockMvc;
@嘲弄
私人用户服务;
@试验
public void saveShouldReturnOK(){
mockStatic(LogHelper.class);
doNothing().when(LogHelper.info(anyString());
....
}
}
欢迎使用堆栈溢出!不幸的是,这个问题不够详细,无法为您提供任何有意义的帮助。请编辑您的问题,以包含问题的最小可复制示例,包括样本输入、首选输出和您迄今为止尝试的代码。