我有以下代码:
@RunWith(PowerMockRunner.class)
@PrepareForTest({RequestUtils.class, OsgiUtil.class})
@PowerMockIgnore({"*"})
public class MyTest
...
@Test
public somMethod(){
....
mockStatic(RequestUtils.class);
when(RequestUtils.getLocale(request)).thenReturn(locale);
}
}
如何替换此代码,使其在没有 @RunWith(PowerMockRunner.class)
的情况下工作?
根据以下描述的原因link我不能使用 @RunWith(PowerMockRunner.class)
最佳答案
看看这个讨论:issues while using @RunWith Annotation and powerMock
其中一个答案建议使用 PowerMockRule
而不是 runner。这个解决方案应该对你有好处。
关于java - 没有 @RunWith(PowerMockRunner.class) 的模拟静态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24141580/