-
Notifications
You must be signed in to change notification settings - Fork 275
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
[BUG?] Ignore not working as expected #480
Comments
Ignore, ignores all. So its not what your comment says. |
Hi @parmi93 As @Letme explained, the Ignore function doesn't work as you think it does. It's not queueing up the ability to ignore a function call AFTER it was expected, it's replacing the expectation with a "nevermind... you can ignore any calls to this function". At first that might seem like a silly choice. But consider the opposite direction:
If we use the same logic as our actual implementation, this is easy... the Ignore directive is replaced with a "actually, I want you to check for If we accepted that it would be queued, as your original assumption was, then what does this mean? Does it need to ignore a particular number of calls before the Expect (which defeats the purpose of ignore)? Does it only want to check the arguments of the last time So, in attempt to keep the syntax consistent, ignore is turned on/off by overrides. :) |
Thanks for the clarification, I get what you mean. I was fooled by a superficial reading of this section of the documentation: Lines 165 to 176 in 9192a95
Specifically:
This led me to think that |
Hm. That IS a confusing description. I guess technically it's true because you can enable and disable the ignore function at different points during a test... but you'd need to actually USE the mocks between those calls. I'm going to reopen this... we'll either need to improve the docs here or make it work better. :) |
Perhaps it would be useful to have a mock like This way I could change my test to the following: //test_my_function.c
#include "bar.h"
#include "mock_foo.h"
void test_my_function()
{
funA_Expect(0, 0);
funB_Expect('x');
funA_StartIgnore(); // I expect any further calls to the funA function to be ignored.
my_function();
} |
Just write |
Yes, I would like calls to |
But what do you expect to happen in situation: void test_my_function()
{
funA_Expect(0, 0);
funB_Expect('x');
funA_StartIgnore(); // I expect any further calls to the funA function to be ignored.
funA_StopIgnore(); // How many calls in between you wanted ignored?
funA_Expect(1, 1);
} This is just start of complexity you hit, if you allow ignore after some time. What about when you add complexity of |
In this situation I would expect that no calls to editRegarding |
Ok, what then do you expect from
Maybe you do not realize, but this is not run at the time of the call, but just expects are placed on the stack and then hit as you call your test function, so timing wise both examples should be the same. |
ohh, I get what you mean, actually what I proposed makes no sense at all! lol maybe the following solution might work:
|
The mock code auto-generated is:
Test is failing with the following message:
The text was updated successfully, but these errors were encountered: