In some situations though, it is helpful to assert on certain arguments after the actual verification. This is also the recommended way of matching arguments because it makes tests clean & simple. Mockito.verify(collaborator).callMethod(captor.capture()) Argument actual captor. Using the ArgumentCaptor we can get the argument instance created internally and used in the collaborator call and thus we can verify it. With that feature we can see what happens internally – we can check ‘what’s inside the box.’ Background Mockito verifies argument values in natural java style: by using an equals() method. This where the Mockito ArgumentCaptor comes into picture. ArgumentCaptor is a nice Mockito feature that can be used to check and validate arguments passed by inside tested portion of code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |