Permalink
Browse files

TEST Acceptance test for history in case of exceptions

  • Loading branch information...
1 parent df73ab4 commit 8e2cb953a3e2e00f766330c6767691117da4d558 @samuelrivas committed Jun 12, 2013
Showing with 32 additions and 0 deletions.
  1. +32 −0 test/acceptance/mok_exceptions.erl
@@ -47,8 +47,40 @@ exceptions_test_() ->
?_assertExit (ouch, mok_exceptions_aux:call({exit, ouch})),
?_assertError(function_clause, mok_exceptions_aux:call(foo))]}.
+exceptions_history_test_() ->
+ {setup,
+ fun() ->
+ Apps = sel_application:start_app(moka),
+ Moka = moka:start(mok_exceptions_aux),
+ moka:replace(Moka, internal, crashy_fun()),
+ moka:load(Moka),
+ %% Do some crashes
+ catch mok_exceptions_aux:call({throw, ouch}),
+ catch mok_exceptions_aux:call({error, doh}),
+ catch mok_exceptions_aux:call({exit, gna}),
+ {Apps, Moka}
+ end,
+ fun({Apps, Moka}) ->
+ moka:stop(Moka),
+ sel_application:stop_apps(Apps)
+ end,
+ fun({_Apps, Moka}) ->
+ History = moka:history(Moka),
+ [match_exception_(throw, ouch, lists:nth(1, History)),
+ match_exception_(error, doh , lists:nth(2, History)),
+ match_exception_(exit , gna , lists:nth(3, History))]
+ end}.
+
%%%_* Private Functions ================================================
+match_exception_(Class, Reason, HistoryEntry) ->
+ ?_assertMatch(
+ {{mok_exceptions_aux, internal},
+ _Args,
+ {exception, Class, Reason}},
+ HistoryEntry
+ ).
+
crashy_fun() ->
fun({throw, X}) -> throw(X);
({exit, X}) -> exit(X);

0 comments on commit 8e2cb95

Please sign in to comment.