4

I'm trying to verify that a function on a mock object is NOT called at all with ANY parameters.

The function on the object I'm mocking is...

- (void)registerUserWithUsername:(NSString*)username password:(NSString*)password;

I'd like to verify that the function is NOT called if the username is blank.

i.e.

[mockService registerUserWithUsername:@"" password:@"Password"];

[verify(mockService, never()) registerWithUsername:....... password:.......];

I'm just not sure what to put in the ...... bits?

Fogmeister
  • 76,236
  • 42
  • 207
  • 306

1 Answers1

11

To specify that it's never called with any parameters, use the anything() matcher:

[verify(mockService, never()) registerWithUsername:(id)anything() password:(id)anything()];
Jon Reid
  • 20,545
  • 2
  • 64
  • 95
  • Is there an equivalent for primitive types? – Zorayr Dec 01 '16 at 22:29
  • 1
    @Zorayr See [How do you specify matchers for non-object arguments?](https://github.com/jonreid/OCMockito#how-do-you-specify-matchers-for-non-object-arguments) – Jon Reid Dec 02 '16 at 01:01