[OCMock][OCMVerify]Why does OCMVerify still pass when I don’t call a method?

387 Views Asked by At

for example:

id mockDelegate = OCMProtocolMock(@protocol(managerDelegate));
self.vc.delegate = mockDelegate;
OCMExpect([mockDelegate someMethod:OCMOCK_ANY]);

... Execute some methods to make vc.m respond to someMethod delegate callback...

OCMVerify(mockDelegate);

I implemented the above method and found that even if the class does not respond to the someMethod method, OCMVerify still judges it passed. Why?

1

There are 1 best solutions below

3
Erik Doernenburg On BEST ANSWER

For using strict mocks, please have a look at section 7 of the documentation: https://ocmock.org/reference/#strict-mocks-and-expectations

It's easy to overlook but you have to use OCMVerifyAll for verifying expectations. OCMVerify is used for something else.