Skip to content

Exception while configuring return behaviors using assertThat argument matchers #3109

Answered by TimvdLippe
gigermocas asked this question in Q&A
Discussion options

You must be logged in to vote

assertArg(arg -> assertEquals("2", arg)) itself returns null. Therefore, the code is equivalent to the following:

		when(bar.parse(assertArg(arg -> assertEquals("1", arg))))
				.thenReturn(1);

		when(bar.parse(null))
				.thenReturn(2);

Since the second invocation does not equal to 1, your matcher fails and it stops there. If you want multiple matchers, then do an assertArg which does a check for multiple allowed values and return these values as well.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by TimvdLippe
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants