%% public interface
-export([no_plan/0, plan/1, done/1]).
-export([running/2]).
--export([test_skipped/2, test_todo/2]).
+-export([test_skipped/2, test_todo/3]).
-export([test_passed/1, test_failed/2, dubious_result/2, test_died/2]).
%% supervision tree API
%% @doc Mark the test as "TODO".
--spec test_todo(test_run_id(), string()) ->
+-spec test_todo(test_run_id(), term(), string()) ->
ok.
-test_todo(TestRunId, Reason) ->
- gen_server:call(TestRunId, {todo, Reason}).
+test_todo(TestRunId, Result, Why) ->
+ gen_server:call(TestRunId, {todo, Result, Why}).
%%%---------------------------------------------------------------------------
%%% supervision tree API
undefined -> 1;
{TestNo, _} -> TestNo + 1
end,
- %io:fwrite("# running test ~B: ~s~n", [NextTestNo, Desc]),
NewState = State#state{test = {NextTestNo, Desc}},
{reply, ok, NewState};
handle_call({skipped, Reason} = _Request, _From,
State = #state{test = {TestNo, TestDesc}}) ->
- % TODO: OK or NOK?
- io:fwrite("ok ~B - ~s # SKIP: ~s~n", [TestNo, TestDesc, Reason]),
+ io:fwrite("ok ~B - ~s # SKIP ~s~n", [TestNo, TestDesc, Reason]),
{reply, ok, State};
-handle_call({todo, Reason} = _Request, _From,
+handle_call({todo, TestResult, Why} = _Request, _From,
State = #state{test = {TestNo, TestDesc}}) ->
- % TODO: OK or NOK?
- io:fwrite("ok ~B - ~s # TODO: ~s~n", [TestNo, TestDesc, Reason]),
+ case TestResult of
+ success ->
+ io:fwrite("ok ~B - ~s # TODO ~s~n", [TestNo, TestDesc, Why]);
+ {failure, _Reason} ->
+ io:fwrite("not ok ~B - ~s # TODO ~s~n", [TestNo, TestDesc, Why]);
+ {dubious, _Value} ->
+ io:fwrite("not ok ~B - ~s # TODO ~s~n", [TestNo, TestDesc, Why]);
+ {died, _Reason} ->
+ io:fwrite("not ok ~B - ~s # TODO ~s~n", [TestNo, TestDesc, Why])
+ end,
{reply, ok, State};
%% unknown calls
{died, Reason} ->
estap_server:test_died(TestRun, Reason)
end;
- {skip, Why} ->
- estap_server:test_skipped(TestRun, Why);
{todo, Why} ->
- estap_server:test_todo(TestRun, Why)
+ %estap_server:test_todo(TestRun, Why)
+ case test(TestFunSpec) of
+ {success, _Result} ->
+ estap_server:test_todo(TestRun, success, Why);
+ {failure, Result} ->
+ estap_server:test_todo(TestRun, {failure, Result}, Why);
+ {dubious, Result} ->
+ estap_server:test_todo(TestRun, {dubious, Result}, Why);
+ {died, Reason} ->
+ estap_server:test_todo(TestRun, {died, Reason}, Why)
+ end;
+ {skip, Why} ->
+ estap_server:test_skipped(TestRun, Why)
end,
run_tests(TestRun, Rest).