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?
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow