Last active
January 4, 2016 09:29
-
-
Save indrekots/8602775 to your computer and use it in GitHub Desktop.
How to capture values with ArgumentCaptor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UserDao userDao = Mockito.mock(UserDao.class); | |
ArgumentCaptor<User> captor = ArgumentCaptor.forClass(User.class); | |
Mockito.verify(userDao).save(captor.capture()); | |
//do some testing logic, eg. call save on a userService object, | |
//which internally uses userDao to save the user object | |
//get the user as it was passed to the save method in userDao | |
User user = captor.getValue() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment