Verify method call with a handle argument on an OCMockito mock

495 Views Asked by At

I have an OCMockito mock of a class QuestionBuilder with the method questionsFromJSON:error:. This method accepts a handle (NSError **)error as an argument. How do I verify the method was called?


I’ve tried:

[verify(builder) questionsFromJSON:@"Fake JSON"
                             error:nil];

and:

NSError *err;
[verify(builder) questionsFromJSON:@"Fake JSON"
                             error:&err];


Both issue the error:

testQuestionJSONIsPassedToQuestionBuilder (QuestionCreationTests) failed:
*** -[NSProxy doesNotRecognizeSelector:questionsFromJSON:error:] called!

1

There are 1 best solutions below

0
On

I don't think OCMockito supports this yet; when I do it using given instead of verify, i get a weird error when the code under test calls the method with the ** argument. If possible you may have to modify your method signature to not take in an NSError** (if you have control over that code).