Calling verify! should raise a Mox.VerificationError if there are too many calls to a mock#141
Calling verify! should raise a Mox.VerificationError if there are too many calls to a mock#141metavida wants to merge 3 commits intodashbitco:mainfrom
verify! should raise a Mox.VerificationError if there are too many calls to a mock#141Conversation
| end | ||
|
|
||
| message = ~r"expected CalcMock.add/2 to be invoked 2 times but it was invoked once" | ||
| test "verifies when mocks are over-called in the process in private mode" do |
There was a problem hiding this comment.
Annotation: The "verifies when mocks are over-called tests are the tests that are currently failing & that would be useful to me in some of the code I'm working on.
verify! should raise Mox.VerificationError if there are too many calls to a mockverify! should raise a Mox.VerificationError if there are too many calls to a mock
Would it be possible to add new tests instead of changing the existing suite? |
617a470 to
f7de7fc
Compare
...instead of changing application.ex
f7de7fc to
3121718
Compare
| end) | ||
| |> Task.yield() |
There was a problem hiding this comment.
Annotation: Other places in this test file use a variable-based syntax instead of piping. For example: https://github.com/dashbitco/mox/blob/31217186dc7b618ea35448d2175377408a574fb3/test/mox_test.exs#L175:L181
I find this shorter, pipe-based syntax a bit nicer since it puts visual attention on the async_nolink call rather than on variable assignment, but I don't feel strongly about this choice. If you'd like me to change the syntax to match the existing code I'm happy to!
Thanks for this comment! It inspired me to simplify this PR so that now it only introduces the 4 new (currently failing) tests. If you think these 4 new tests deserve to be in their own I've separated the other, tangential improvements to |
|
Perfect, Yes, this looks good to me. Looking forward to a possible solution. :) |
|
@metavida any chance you're picking this up anytime soon? Otherwise, I can give it a try. |
|
Go for it! I do not have any near term plans to work on this.
|
Similar to comments in Issue #32, there are certain cases when we want to assert that a mocked function is never called (or is not over-called) but where the
expected calls happen within code that either async or has aggressive error handling. In these cases it's desirable forverify!(andverify_on_exit!) to inform the user when an expectation has been violated by receiving too many calls.Currently this PR does not implement a solution but does contribute 4 net-new
verify!unit tests that should begin passing once this behavior is implemented.Does this seem like a reasonable request/approach?