Issue
The Mockito documentation has this example
//create an inOrder verifier for a single mock
InOrder inOrder = inOrder(singleMock);
//following will make sure that add is first called with "was added first, then with "was added second"
inOrder.verify(singleMock).add("was added first");
inOrder.verify(singleMock).add("was added second");
How to make it return "ducks in a row"
when add is first called with "was added first, then with "was added second"?
(assume for example purposes, the List returns a String).
Update:
It appears that Mockito cannot handle mocking of states in mock objects. As Jeff Bowman suggested, I had to implement a fake object instead.
I wish that Mockito would be enhanced to allow specification of states. After all, when a compiler generates assembly, Yacc creates a state machine out of our language rules.
@moderator. please cancel the bounty since it cannot be done in mockito.
Solution
It appears that Mockito cannot handle mocking of states in mock objects. As Jeff Bowman suggested, I had to implement a fake object instead.
Answered By - likejudo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.