问题描述
完全错误:
org.mockito.exceptions.misusing.MissingMethodInvocationException:when() requires an argument which has to be 'a method call on a mock'
这是我要介绍的方法:
public static String getCurrentTimeStamp() {
Date date = new Date();
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",Locale.ENGLISH);
formatter.setTimeZone(TimeZone.getTimeZone("EST"));
return formatter.format(date);
}
我正在使用的测试用例:
SearchService es = PowerMockito.mock(SearchService.class);
PowerMockito.when(es.getCurrentTimeStamp()).thenReturn("2020-10-10 10:12:30");
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)