jmockit 模拟同一个函数多次调用每次返回不同结果

new Expectations(){{
calendarService.getGeneralCalendar((Date)any);
returns(null, new AbrahamResult<HolidayCalendar>() {{setSuccess(false);}},
new AbrahamResult<HolidayCalendar>() {{setSuccess(true);
setResult(holidayCalendar);}});
times =3;
}};

result = xx;// 每次返回结果都相同
returns(第一次结果,第二次结果,第n次结果)//按调用的次数返回指定结果
posted @ 2018-06-04 17:25  yangming0322  阅读(2861)  评论(0编辑  收藏  举报