Exception while configuring return behaviors using assertThat
argument matchers
#3109
-
When configuring return behaviors using
(this is a trivial example, in my actual code I'm using a recursive comparison assertion from AssertJ for matching complex objects)
I don't understand this, the test hasn't actually ran, the exception is triggered by the configuration of the second return behavior. I'm I missing something here? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Since the second invocation does not equal to 1, your matcher fails and it stops there. If you want multiple matchers, then do an |
Beta Was this translation helpful? Give feedback.
-
That doesn't seem intuitive to me. If I don't use the
I would assume I would get the same behavior between both types of argument matchers. I'm currently in a process of updating my tests, before trying to migrate to
It also works fine if I switch the Also I'm not seeing how I can use a single argument matcher that returns multiple values depending on the argument. Can you elaborate? |
Beta Was this translation helpful? Give feedback.
-
@TimvdLippe, sorry to bump this, as you selected an answer already you may be missing my response. |
Beta Was this translation helpful? Give feedback.
assertArg(arg -> assertEquals("2", arg))
itself returnsnull
. Therefore, the code is equivalent to the following: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.