Closed lyahdav closed 7 years ago
Apologies, I could have sworn that I had replied to this issue. That said, you are correct that OCMVerify verifies the invocation of bar
on foo
. There's only so much you can do with macros and runtime trickery. As soon as code is executed inside the OCMVerify
macro, OCMock has to assume you want to verify those invocations. How else would it know not to verify the first invocation (of bar
) but to verify the second one (of baz
)? Even a convention that would say that only the last invocation is meant to be verified seems impossible to implement, because how would OCMock know at the point when bar
is invoked that there will be another invocation in the future?
Given the following classes:
And given the following unit test:
The test passes, but I expect it to fail because
baz
was never called onbar
. I can get the test to fail if I change theOCMVerify
line to:OCMVerify([bar baz]);
If I delete the
[foo bar]
line, instead I get a failure:OCMockObject(Foo): Method bar was not invoked.
This error is strange because I am trying to verify that
baz
was called, yet the error mentionsbar
. Is it possible this is becauseOCMVerify
verifies the first method call in the macro?