-
-
Notifications
You must be signed in to change notification settings - Fork 231
Open
Labels
Description
Mocking a covered module multiple times in unit tests cause the tests to fail.
Reproduction Steps
Sample code:
-module(my_repro_module).
-include_lib("eunit/include/eunit.hrl").
first_test() ->
cover:compile_beam_directory("PATH_TO_DIRECTORY which contains test_module"),
meck:new(test_module),
meck:expect(test_module, read, fun(_, _) -> ok end),
meck:unload(test_module).
second_test() ->
meck:new(test_module),
meck:expect(test_module, read, fun(_, _) -> ok end),
meck:unload(test_module).
Result:
eunit:test(my_repro_module, [verbose]).
module 'my_repro_module'
my_repro_module: first_test...[0.365 s] ok
my_repro_module: second_test...*skipped*
undefined
*unexpected termination of test process*
::{terminated,[{io,format,
[<0.5771.0>,
"WARNING: Deleting data for module ~w imported from~n~tp~n",
[test_module,
["PATH_...test_module.1438497.coverdata",
"PATH_...test_module_meck_original.1438497.coverdata"]]],
[]},
{cover,remove_imported,2,[{file,"cover.erl"},{line,1362}]},
{cover,fix_state_and_result,3,[{file,"cover.erl"},{line,1496}]},
{cover,main_process_loop,1,[{file,"cover.erl"},{line,664}]}]}
=======================================================
Observed behavior
If I comment out meck:unload(test_module).
in second_test(), the test will pass.
If I add c:l(test_module)
at the start of second_test(), the test will pass.
Versions
- Meck version: 0.8.12
- Erlang version: OTP 21
[Add any other environment or test framework related information here, such as
what OS you are using and how Erlang is installed]
dcsommer