Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Argument captor mockito

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?

like image 421
user123 Avatar asked Feb 07 '13 20:02

user123


1 Answers

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());
like image 99
Rachel Gallen Avatar answered Oct 03 '22 07:10

Rachel Gallen