问题描述
我的课堂上有下面的方法,
public boolean isExecutionDone() {
boolean flag = false;
long NowPlus5Minutes = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(5);
while (!flag) {
if (System.currentTimeMillis() == NowPlus5Minutes) {
flag = true;
}
}
return flag;
}
我正在尝试编写一个junit测试用例,
@Test
public void isExecutionDonetest(){
powermockito.mockStatic(System.class);
// powermockito.when(System.currentTimeMillis()+TimeUnit.MINUTES.toMillis(5)).thenReturn(1603768243291l);
// powermockito.when(System.currentTimeMillis()).thenReturn(1603768543291l);
powermockito.when(System.currentTimeMillis()).thenReturn(1l);
powermockito.when(System.currentTimeMillis()).thenReturn(300005l);
Mockito.when(myTestClass.isExecutionDone()).thenReturn(true);
}
,我的MyTestClass带有@InjectMock和Test类,并带有以下注释,
@PowerMockIgnore("javax.management.*")
@RunWith(powermockrunner.class)
@PrepareForTest(MyTestClass .class)
我如何将junit测试用例改正为isExecutionDone()方法。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)