【发布时间】:2015-10-22 22:43:48
【问题描述】:
我希望这个在主管模块中:
stop() ->
exit(whereis(mousetrap_sup), kill).
所以一个简单的测试可能会这样做:
stop_invokes_exit_test() ->
meck:new(erlang, [unstick, passthrough]),
meck:expect(erlang, whereis, 1, a_pid),
meck:expect(erlang, exit, 2, true),
mousetrap_sup:stop(),
?assert(meck:called(erlang, exit, [a_pid, kill])).
毫不奇怪,它挂了。
我可以看到在哪些地方可能无法通过测试来执行此代码,但有什么办法吗?
【问题讨论】: