Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macros should enforce recording of only one mock invocation #478

Open
dmaclach opened this issue Jan 8, 2021 · 1 comment
Open

Macros should enforce recording of only one mock invocation #478

dmaclach opened this issue Jan 8, 2021 · 1 comment

Comments

@dmaclach
Copy link
Contributor

dmaclach commented Jan 8, 2021

Right now it is possible to write code like:

    id mock = OCMClassMock([NSUUID class]);
    OCMExpect([mock UUID]).andReturn(mock);
    OCMExpect([[mock UUID] UUIDString]).andReturn(@"Hello");
    [NSUUID UUID];
    [NSUUID UUID];
    OCMVerifyAll(mock);

That will pass even though it's obviously not what was intended. While this seems a little contrived, it's actually easier to fall into when using properties that themselves are being mocked so you have something like.

    OCMExpect([foo bar])
    OCMExpect([foo.bar bam])

We still do want to support the case however where foo.bar is not a stub.

I believe we should throw an assertion whenever the recorded stub is not the last invocation in the macro.

@dmaclach
Copy link
Contributor Author

dmaclach commented Jan 8, 2021

Note that I'm preparing a fix for this. Just wanted to record the issue.

@dmaclach dmaclach changed the title Macros should enforce that recording of only one mock invocation Macros should enforce recording of only one mock invocation Jan 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant