2014年3月23日星期日

Argument capture in Mockito

Interestingly, the way that Mockito captures argument is afterwards! So you can basically write code like this:

   mock.doSomething(actualArgument);

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

没有评论:

发表评论