-
Notifications
You must be signed in to change notification settings - Fork 86
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
Setting expectations in a function fails #311
Comments
All expectations set up are valid in the scope of the set up, so You can use |
Thanks for the quick answer. I went looking for examples with NAMED_ALLOW_CALL and didn't find any, but I guess it would look something like the folowing:
However, my mock needs 10-15 expectations (don't ask), so I guess I will have to create a vector of Tomorrow, I'll make a PR for a documentation change to help other people. |
That looks right. I've done it that way too. The vector is nice. I'm a bit surprised that you didn't find any examples of |
I was looking in the cookbook, which seemed the best place to start. All the examples there were ALLOW_CALL or REQUIRE_CALL, so I presumed that's what I should use. I'll add a section there tomorrow, when I have time. |
Good to see that I hadn't found missing functionality in your library :-) |
Is there something I should do here, or can I close the issue? |
I have a very large class I want to mock, and I created a function to set all these expectations, which I then call from the test.
Sadly, this always fails. It would appear that the
ALLOW_CALL
invocations create local expectation objects which need to be alive when the mock is used.I appreciate that this might be a very large change to make to the library, but if not, this should be documented in the FAQ.
Here's my sample code:
The text was updated successfully, but these errors were encountered: