Here's a test project with 2 files that shows the problem.
You need 2 modules
- in the first module you should have a eunit test
- in the second module you should meck any function from the first module
When you run eunit, the meck fails at 'meck:expect' with 'undefined' exception.
How to reproduce:
./rebar get-deps
./rebar compile
mkdir -p .eunit
erlc -o .eunit/ *.erl
erl -pa deps/meck/ebin/ -pa .eunit/ -eval "eunit:test([t1,t2])" -s init stop
Diagnostics:
Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V5.10.3 (abort with ^G)
1> t2.erl:17:<0.39.0>: before meck:new
t2.erl:19:<0.39.0>: before meck:expect
undefined
*unexpected termination of test process*
::killed
=======================================================
Failed: 0. Skipped: 0. Passed: 1.
One or more tests were cancelled.
=ERROR REPORT==== 16-Dec-2014::11:53:26 ===
** Generic server t1_meck terminating
** Last message in was {'EXIT',<0.39.0>,killed}
** When Server state == {state,t1,
[{stop,1},{foo_test_,0},{test,0}],
{dict,1,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],[],[],[],[],[],[],[],[],[],[],
[[{stop,1}|
{{stop,1},
[{{args_matcher,['_'],<<>>,false},
{meck_exec,#Fun<t2.3.55841443>}}]}]],
[],[],[],[]}}},
true,[],
{false,no_binary},
false,
{<0.44.0>,{<0.39.0>,#Ref<0.0.0.42>}},
[]}
** Reason for termination ==
** killed
Though, if checked separately, tests pass:
$ erl -pa deps/meck/ebin/ -pa .eunit/ -eval "eunit:test([t1])" -noshell -s init stop
Test passed.
$ erl -pa deps/meck/ebin/ -pa .eunit/ -eval "eunit:test([t2])" -noshell -s init stop
t2.erl:17:<0.34.0>: before meck:new
t2.erl:19:<0.34.0>: before meck:expect
Test passed.