From c6c141581e0939a985796f5c402df0932e97d193 Mon Sep 17 00:00:00 2001 From: Stanislaw Klekot Date: Mon, 10 Oct 2016 22:57:28 +0200 Subject: [PATCH] all_ok() returns more meaningful error report. --- src/estap.erl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/estap.erl b/src/estap.erl index f1deb08..aff899d 100644 --- a/src/estap.erl +++ b/src/estap.erl @@ -277,13 +277,22 @@ plan(TestCount) when is_integer(TestCount) -> %% indicate that the test sequence passed or failed. -spec all_ok() -> - true | false. + ok | {error, term()}. all_ok() -> TestRun = get_test_run(), {Planned, Total, Failed, _TODO} = estap_server:get_status(TestRun), estap_server:done(TestRun), % this ends estap_server, so it goes last - (Failed == 0) and ((Planned == undefined) or (Planned == Total)). + case Failed of + 0 when Planned == undefined -> + ok; + 0 when Planned == Total -> + ok; + 0 when Planned /= Total -> + {error, {bad_plan, [{plan, Planned}, {run, Total}]}}; + _ -> + {error, {failures, [{failed, Failed}, {plan, Planned}, {run, Total}]}} + end. %%%--------------------------------------------------------------------------- -- 1.7.10.4