Reputation: 281
I have been doing a bit of reading around argument captor and the more I read about it, the more I get lost. Can someone take the pain of explaining it with an example?
Upvotes: 19
Views: 16579
Reputation: 28553
According to docs, this is deprecated. You should use factory method forClass(Class) to create captors instead to avoid NullPointerExceptions. see here
Example:
ArgumentCaptor<Person> argument = ArgumentCaptor.forClass(Person.class);
verify(mock).doSomething(argument.capture());
assertEquals("John", argument.getValue().getName());
Upvotes: 25