eunit test for timeout
-
25-05-2021 - |
Question
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?
La solution
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.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow