Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Verify a method was never called with OCMock 3

How do I verify a method is never called with OCMock 3?

I was thinking something like this:

XCTAssertThrows(OCMVerify([_restDataSource getSomeStuff:[OCMArg any]]));

But it seems like OCMVerify doesn't throw for a fail.

like image 787
Ev. Avatar asked Feb 25 '15 22:02

Ev.


2 Answers

Please see first point under http://ocmock.org/reference/#advanced-topics

Note that reject at this point in time requires the old-style syntax and it must be called before the method may be invoked, ie.

// first set up the mock
[[mock reject] methodThatShouldNotBeCalled]
// then call method that should not result in the call

For a glimpse on what's planned, see https://github.com/erikdoe/ocmock/issues/109

like image 64
Erik Doernenburg Avatar answered Oct 04 '22 13:10

Erik Doernenburg


As I answered here, starting from version 3.3 OCMock has OCMReject macro.

like image 21
Ruslan Mansurov Avatar answered Oct 04 '22 14:10

Ruslan Mansurov