-
-
Notifications
You must be signed in to change notification settings - Fork 231
Open
Milestone
Description
It appears that the value returned by meck:num_calls(...)
only updates after the called function has returned. This makes verifying behaviour around long running functions difficult.
Reproduction Steps
Here's a passing eunit test to recreate the scenario I have.
num_calls_test() ->
meck:new(dummy, [non_strict]),
meck:expect(dummy, test, fun
(short) -> ok;
(long) -> receive stop -> ok end
end),
?assertEqual(ok, dummy:test(short)),
?assertEqual(1, meck:num_calls(dummy, test, [ short ])),
Pid = spawn(fun() -> dummy:test(long) end),
timer:sleep(100),
?assertEqual(0, meck:num_calls(dummy, test, [ long ])),
Pid ! stop,
timer:sleep(5),
?assertEqual(1, meck:num_calls(dummy, test, [ long ])),
meck:unload(dummy).
Expected behavior
I would expect that meck:num_calls
would update as soon as the function is entered and the runtime of that function to have no effect. I would exepect the first call to ?assertEqual(0, meck:num_calls(dummy, test, [ long ])),
to fail with a value 1 being returned instead
Versions
Meck version: 0.8.4
Erlang version: 18.2.1