0
我如何测试一个gen_fsm确实超时与eunit?eunit测试超时
{ok, GH} = gen_fsm:start_link(myFSM, [], []),
//after 15 sec it should timeout if no messages received.
//What must I write here to test it?
我如何测试一个gen_fsm确实超时与eunit?eunit测试超时
{ok, GH} = gen_fsm:start_link(myFSM, [], []),
//after 15 sec it should timeout if no messages received.
//What must I write here to test it?
我相信这是一个解决办法:
{ok, GH} = gen_fsm:start_link(myFSM, [], []),
Ref = erlang:monitor(process,GH),
receive
{'DOWN', Ref, process, GH, normal} ->
test_passed
after
15000 ->
?assert("FSM did not die.") % will always fail
end.
我得到:xxx_tests:xxx_timeout_test ... *超时* 未定义 ============== ========================================= 失败:0.跳过:0。通过:0. 一个或多个测试被取消。 错误 – Daniel 2012-03-22 20:03:14
解决了,味精不是关于进程下降,而是关于测试本身。用{timout,30,fun() - > *测试代码*}括起来。现在它起作用了。 – Daniel 2012-03-23 09:23:13