Replies: 1 comment 2 replies
-
Btw: I also tried inOrder without success: @Test
@DisplayName("verify two different calls with asserArg() and inOrder()")
void verifyTwoDifferentCallsWithAsserArgAndInOrder() {
someMock.someMethod(1, "any string");
someMock.someMethod(2, "any string");
final InOrder inOrder = inOrder(someMock);
inOrder.verify(someMock).someMethod(
assertArg(someInt -> assertThat(someInt).isEqualTo(1)),
anyString()
);
inOrder.verify(someMock).someMethod(
assertArg(someInt -> assertThat(someInt).isEqualTo(2)),
anyString()
);
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When verifying multiple different calls to a method of a mock, it is possible to call
verify()
twice for each invocation.This will work when not using matchers:
This will also work when using simple matchers:
However, it does not work when using
assertArg()
:The reason behind this is probably the inner assertion failing on at least one of the calls.
So far, the only way I know how to test something like this is to use ArgumentCaptors:
Now, my question: Is there any way to do this without using an ArgumentCaptor?
Beta Was this translation helpful? Give feedback.
All reactions