KallDrexx
KallDrexx

Reputation: 27803

Is there a way to make EUnit not bomb on gen_server exit (and consider it a failure)?

I have several EUnit tests to test functionality of a gen_server I have created. For example, let's take the following test for an IRC server I am writing:

empty_channel_details_when_getting_details_of_channel_that_does_not_exist_test() ->
  start(),
  ?assertMatch({ok, #channel_details{name = "name", users = #{}}}, irc_channel_manager_server:get_channel_details("name")).

Of course, since i am creating this with TDD methodologies running my gen_server is crashing with a case_clause exit, because I obviously hadn't coded that test case yet.

The problem with this is the output this causes EUnit to display, which is:

=======================================================
  Failed: 0.  Skipped: 0.  Passed: 0.
One or more tests were cancelled.
error

I personally consider this wrong. Not only did my test obviously fail, but there were a total of 3 test cases written in this test module and one failure means none of the other two tests were even attempted.

Is there any way to make EUnit treat an exit or exception as a failure and not cause it to cancel the test run? It makes it really difficult to determine the scope of an accidental breaking change.

Upvotes: 1

Views: 68

Answers (0)

Related Questions