<div dir="ltr">Hi, I am relatively new to erlang and I am trying to write a project to grasp the language and otp basics. In my application, I am using e-units for testing. here is some sample code<div><br></div><div><br></div>

<div><div>get_room_get_code_test() -></div><div>    chat:stop(),</div><div>    Code = 1,</div><div>    ?assertEqual(ok, chat:start()),</div><div>    {ok, Room} = start_link(Code),</div><div>    ?assertEqual({ok, 1}, get_code(Room)),</div>

<div>    ?assertEqual({ok, Room}, get_room(1)),</div><div>    ?assertEqual(ok, chat:stop()).</div></div><div><br></div><div><br></div><div style>all of my codes have this structure.</div><div style><br></div><div style>1) Stop chat server, if it is running (if previous test failed before stopping running server)</div>

<div style>2) Start chat server.</div><div style>3) do tests.</div><div style>4) stop server.</div><div style><br></div><div style><br></div><div style>Writing this every time is look really bad. (even if would make start_test_env, stop_test_env methods, I would still need to write a structure to make sure test environment is properly destroyed for every failed test.)</div>

<div style><br></div><div style>So I decided to write it with common test.</div><div style><br></div><div style><div>init_per_suite(Config) -></div><div>    ok = chat:start(),</div><div>    error_logger:info_msg("Chat application stopped~n"),</div>

<div>    Config.<br></div><div><br></div><div><div>end_per_suite(_Config) -></div><div>    ok = chat:stop(),</div><div>    error_logger:info_msg("Chat application stopped~n"),</div><div>    ok.</div></div><div>

<br></div><div>get_room_get_code_test_case() -><br></div><div><div>    [].</div><div><br></div><div>get_room_get_code_test_case(_Config) -></div><div>    Code = 1,</div><div>    {ok, Room} = c_room:start_link(Code),</div>

<div>    {ok, Code} = c_room:get_code(Room),</div><div>    {ok, Room} = c_room:get_room(1).</div></div><div><br></div><div><br></div><div><br></div><div style>With common  tests my tests seems a lot better. But if I have an error to console. instead of it goes to common test report.</div>

<div style><br></div><div style>I was wondering what people are using in those situations.</div><div style><br></div><div style>What I want to do is to run the test cases every time I save my files to see if anything is broken. So I do not really want to run the test cases and go to my browser to see the results every time I save a file.</div>

<div style><br></div><div style>Another thing is ?assert macros.  Those macros give a nice output in eunits but common_tests does not have them. So it seems to me like we do not really interested in common_test output. we only want to see if it tests. So this means they are only for to run before going production?</div>

<div style><br></div><div style>Any comment on this would be appreciated.</div><div style><br></div></div></div>