0
有沒有什麼辦法可以設置JMock的onConsecutiveCalls方法,以便循環回到第一個行爲,當它到達傳遞參數列表的末尾時傳遞? 在下面的示例代碼中,我希望模擬返回true->false->true->Ad infinitum
。Jmock循環連續調用
模擬設置:
final MyService myServiceMocked = mockery.mock(MyService.class);
mockery.checking(new Expectations() {{
atLeast(1).of(myServiceMocked).doSomething(with(any(String.class)), with(any(String.class)));
will (onConsecutiveCalls(
returnValue(true),
returnValue(false)
));
}});
方法調用DoSomething的方法:
...
for (String id:idList){
boolean first = getMyService().doSomething(methodParam1, someString);
boolean second = getMyService().doSomething(anotherString, id);
}
...