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