objective-cunit-testingocmockito

How to stub multiple method calls in OCMockito


I am trying to unit test a method that calls the same method on a mocked object multiple times. In Java, using Mockito, I could provide multiple results to return from the method:

when(mock.someMethod()).thenReturn(1,1,0);

I would like to do the same for OCMockito if possible. Something like:

[given([mock someMethod]) willReturn:@1,@1,0];

Thanks for any input!


Solution

  • OCMockito doesn't support that at this time. Feel free to submit a new issue with a feature request.

    In the meantime, you may want to use a hand-rolled mock to accomplish what you need.