Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OCMockito verify with any arguments

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?

like image 271
Fogmeister Avatar asked Dec 21 '22 07:12

Fogmeister


1 Answers

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

[verify(mockService, never()) registerWithUsername:(id)anything() password:(id)anything()];
like image 178
Jon Reid Avatar answered Jan 04 '23 11:01

Jon Reid