unite icon indicating copy to clipboard operation
unite copied to clipboard

Failing test is not reported

Open rlipscombe opened this issue 9 years ago • 2 comments

I have a single failing test (shown as 'F' in the progress), but instead of details, all I get from unite is the following error:

Error in process <0.1415.0> with exit value: {badarg,[{lists,member,[63,undefined],[]},
{unite_compact,format_macro_string,1,[{file,"src/unite_compact.erl"},{line,283}]},
{unite_compact,format_info,2,[{file,"src/unite_compact.erl"},{line,111}]},
{unite_compact,print_failure...

rlipscombe avatar Nov 06 '14 15:11 rlipscombe

Ah, it's because I have some custom assertion exceptions (that wrap meck:called!), which don't include expression in the assertion_failed error:

assert_not_called_failed(AtModule, AtLine, Module, Function, Args) ->
    History = [format_history(H) ||
        H = {_Pid, {M,F,_A}, _Result} <- meck:history(Module), M =:= Module, F =:= Function],
    erlang:error({assertion_failed,
                  [{module, AtModule},
                   {line, AtLine},
                   {expected, lists:flatten(io_lib:format("No call to ~p:~p(~s)",
                       [Module, Function, format_arg_list(Args)]))},
                   {history, History}]}).

I can work around this by changing the error tag (assertNotCalled_failed, for example), but it'd be nice if unite fell back to a catch-all clause or something.

rlipscombe avatar Nov 06 '14 15:11 rlipscombe

(only 4 years too late... 🙄)

Currently, such a failure looks like this:

 1) custom_failure_test/0 (_build/demo+test/lib/unite/test/unite_test.erl:10)
    Uncaught exception!
    exception error: {assertion_failed,[{module,foobar},
                                        {line,100},
                                        {expected,"No call to mymod:myfun(A, B)"},
                                        {history,[]}]}
      in function  unite_test:custom_failure_test/0 (_build/demo+test/lib/unite/test/unite_test.erl, line 10)

The only way to prettify it even more I think would be to provide a custom formatter fun for home-grown errors that Unite can be configured with...

eproxus avatar Mar 21 '18 12:03 eproxus