2
我是一个meck(和Erlang)的新手,我正在用meck挣扎。我收到以下错误:使用meck(Erlang)时,什么原因导致“未嘲笑”错误?
=ERROR REPORT==== 27-Jan-2014::16:20:05 ===
Error in process <0.1825.0> with exit value: {{not_mocked,substatsDb},
[{meck_proc,gen_server,3,[{file,"src/meck_proc.erl"},{line,443}]},{meck_code_gen,exec,4,
[{file,"src/meck_code_gen.erl"},{line,147}]},{substats,loop,1,
[{file,"/Users/uyounri/gitsandbox/subpub/src/su...
在我的测试开始时我宣布的模块被嘲笑:
meck:new(substats)
在我测试的最后我做的最后一件事是卸载该被嘲笑嘲笑模块:
meck:unload(substats)
的嘲笑似乎是如预期工作直到接近当产生上述错误的测试结束。
谢谢, 富
EDIT 添加2 debugFmt()线似乎已经解决的问题?;至少我不会再犯错误了。这里是一个被修改的完整功能:
stop(_) ->
meck:expect(substatsDb, stop, 1, fun(dbconn) -> ok end),
substats:stop(),
%% Note: this and the next ?debugFmt() calls prevent a meck
%% exit error. They both have to be present to prevent the error
?debugFmt("stop:~n", []),
meck:unload(substatsDb),
?debugFmt("stop: exit~n", []).