mockingmockitoargument-matcher

Alternative to extending ArgumentMatcher for argument verification for mockito


I was wondering if there is more elegant way to verify the arguments other than using a class that extends ArgumentMatcher?

Thanks.


Solution

  • Are you looking for ArgumentCaptor as a way of doing this? Refer to http://docs.mockito.googlecode.com/hg/latest/org/mockito/Mockito.html#captors . This lets you perform whatever checks you like on the values that were passed to your mock's methods. It's often much simpler than setting up an ArgumentMatcher.