Verify details of argument passed to the mocked object

Mockito, my favoritte mock library, introduced ArgumentCaptor with 1.8. ArgumentCaptor allows you to capture and store arguments passed the mocked methods. The captured arguments are available with the methods like getValue and getValues. So, the arguments can be easily verified by using standart JUnit assertions.

ArgumentCaptor argument = ArgumentCaptor.forClass(Person.class);
verify(mock).doSomething(argument.capture());
assertEquals("John", argument.getValue().getName())