I want to test a method of a mock is called in order using different parameters:
I tried to use the following code:
InOrder inOrder = inOrder(myobject);
inOrder.verify(myobject).println(any(String.class));
inOrder.verify(myobject).println(any(String.class));
inOrder.verify(myobject).println("");
inOrder.verify(myobject).println("myfolder");
inOrder.verify(myobject).println("");
inOrder.verify(myobject).println(System.getProperty("user.home"));
However, this does not seem to work as it gave me an error says
inOrder.verify(myobject).println(any(String.class));
has been called for 8 times. This is correct through, but it fails to address the order.
I want to check:
The println method of `myobject` is first called with any string parameter
Then it is called with any string parameter again
Then it is called by an empty string
Then it is called by string "myfolder"
......
How can I achieve this?
EDIT:
Error message is:
org.mockito.exceptions.verification.VerificationInOrderFailure:
Verification in order failure:
printWriter.println(<any>);
Wanted 1 time:
-> at com.mycompany.MyUnitTest.mytest(MyrUnitTest.java:107)
But was 8 times.