June 9, 2012
Argument Captor for Objective-C

For my small projects Qmind and Qdesktop I needed a Objective-C counterpart of Mockito’s ArgumentCaptor. As far as I can see, OCHamcrest or OCMockito do not offer this functionality. Thus, I wrote an OCHamcrest matcher which does the job: ArgumentCaptor.zip


ArgumentCaptor *captor = argCaptor();

[someMock someMessage:someArgument];
[verify(someMock) someMessage:captor];

id argument = captor.argument;
assertThat(argument, is(someArgument));

BTW, I’m using the ARC.

10:51pm  |   URL: http://tmblr.co/Z-oSPxN4EktM
(View comments
Filed under: cocoa testing 
Blog comments powered by Disqus