I'm writing an ArgumentMatcher and the guts of the comparison come down to something like:
return A.value().equals(B.value()) && A.name().equals(B.name());
Unfortunately, when the doesn't pass, Mockito just tells me it failed. I want to add a custom message like "Values don't match" or "Names don't match" (of course I'd like to give more info, but until I can figure out this simple case, what's the point of going any further).
Previously (before working with Mockito), I remember matchers having two methods - one to check the match and one to generate a failure message (true, it was a pain to write both methods, but I miss the second method now).
Any idea how to do this? Any help is appreciated!
I get it now. Hamcrest provides a "describeTo" method. This is equivalent to the method I remember from EasyMock. You simply add your error conditions to the Description object, and viola, you have a better failure message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With