1

如何测试 gen_fsm 是否确实与 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?
4

1 回答 1

1

我相信这是一种解决方案:

{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.
于 2012-03-22T13:13:54.173 回答