-
Notifications
You must be signed in to change notification settings - Fork 77
Expect that a mocked function is never called #32
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
Comments
@jgashe if you try to call something that has no expectation it will just raise today. And your test should fail accordingly. |
I'd like to have a test pass if something is never called. The function never being called is my expected behavior. Imagine code like this:
If I want to test both branches of this, I'd call Mox doesn't let me do this because it raises if the Mock doesn't have any expectation, and doesn't have a pattern match of |
What do you mean? If you don't set any expectation that is fine by Mox. |
Oh yeah you're totally right. Closed. |
@josevalim If the call to a function with no expectations takes place asynchronously, though, the |
@NikitaAvvakumov if the process is not linked to the test process in any way, then the failures won't cascade, and your test won't fail. this is a general property of Elixir, not necessarily related to mox. |
@josevalim But in this particular case, could test failures be enforced by adding to Mox either |
@NikitaAvvakumov oh, I see what you mean. That sounds good to me. Can you please send a PR? |
@josevalim I'll gladly give it a shot. Which option sounds better to you - |
|
@josevalim just reading through older issues. this seems to be addressed in #35 which is already merged, right? |
correct! thanks! |
Mox requires that, if a mock is used, we set an expectation for it. But
expect
requires that the number of invocations be greater than 0. Other mock libraries (like mockito) allow for verifying that a mocked method is never called. This would probably be useful for Mox.Thoughts?
The text was updated successfully, but these errors were encountered: