문제

How can I test that a gen_fsm does indeed timeout with 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?
도움이 되었습니까?

해결책

I believe this is one solution:

{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.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top