Search code examples
objective-cocmockito

Is there a way in OCMockito to make stubs fail when an unknown method is called?


When creating a stub in OCMockito, I use calls like this to stub out method calls and their return values:

[given([stubObject myMethod]) willReturn:someValue];

The problem I have is that if I don't define a method an that method gets called during the test, the default seems to be to return nil. This can lead to sneaky bugs since my real methods are asserted never to return nil and therefore the return value is not tested in the code calling the method.

Is there a way to change this default behavior or maybe to test if anything was called on the object apart from the few methods I'm stubbing?


Solution

  • No, OCMockito stubs are always "nice". If you want "strict" stubs, OCMock may suit you better.