aboutsummaryrefslogtreecommitdiffstats
path: root/lib/eunit/src/eunit_surefire.erl
diff options
context:
space:
mode:
authorMagnus Henoch <[email protected]>2011-03-10 10:18:37 +0000
committerFredrik Gustafsson <[email protected]>2012-08-10 10:57:23 +0200
commit95a78de4810ca25f7175d8eb7bb8f05e38034122 (patch)
tree265a58dfb42a2654f6b25ca40a1b8b28f74b1a4a /lib/eunit/src/eunit_surefire.erl
parent5f9ad541eb520162d86bdc5bcf58e235ced7e786 (diff)
downloadotp-95a78de4810ca25f7175d8eb7bb8f05e38034122.tar.gz
otp-95a78de4810ca25f7175d8eb7bb8f05e38034122.tar.bz2
otp-95a78de4810ca25f7175d8eb7bb8f05e38034122.zip
Include fixture setup and cleanup errors in Eunit Surefire report
An error during fixture setup means that some tests could not be run, and therefore needs to be highlighted in the test report. Likewise, a cleanup failure is often a problem that needs to be looked into. Since setup and cleanup are not part of any single test in Eunit's view, I include them as phantom test cases in the report whenever they fail.
Diffstat (limited to 'lib/eunit/src/eunit_surefire.erl')
-rw-r--r--lib/eunit/src/eunit_surefire.erl30
1 files changed, 27 insertions, 3 deletions
diff --git a/lib/eunit/src/eunit_surefire.erl b/lib/eunit/src/eunit_surefire.erl
index 69f471d130..46b8c8b503 100644
--- a/lib/eunit/src/eunit_surefire.erl
+++ b/lib/eunit/src/eunit_surefire.erl
@@ -156,9 +156,33 @@ handle_end(test, Data, St) ->
St#state{testsuites=store_suite(NewTestSuite, TestSuites)}.
%% Cancel group does not give information on the individual cancelled test case
-%% We ignore this event
-handle_cancel(group, _Data, St) ->
- St;
+%% We ignore this event...
+handle_cancel(group, Data, St) ->
+ %% ...except when it tells us that a fixture setup or cleanup failed.
+ case proplists:get_value(reason, Data) of
+ {abort, {SomethingFailed, Exception}}
+ when SomethingFailed =:= setup_failed;
+ SomethingFailed =:= cleanup_failed ->
+ [GroupId|_] = proplists:get_value(id, Data),
+ TestSuites = St#state.testsuites,
+ TestSuite = lookup_suite_by_group_id(GroupId, TestSuites),
+
+ %% We don't have any proper name. Let's give all the
+ %% clues that we have.
+ Name = case SomethingFailed of
+ setup_failed -> "fixture setup ";
+ cleanup_failed -> "fixture cleanup "
+ end
+ ++ io_lib:format("~p", [proplists:get_value(id, Data)]),
+ Desc = format_desc(proplists:get_value(desc, Data)),
+ TestCase = #testcase{
+ name = Name, description = Desc,
+ time = 0, output = <<>>},
+ NewTestSuite = add_testcase_to_testsuite({error, Exception}, TestCase, TestSuite),
+ St#state{testsuites=store_suite(NewTestSuite, TestSuites)};
+ _ ->
+ St
+ end;
handle_cancel(test, Data, St) ->
%% Retrieve existing test suite:
[GroupId|_] = proplists:get_value(id, Data),