[erlang-questions] EUnit failure stack traces

Ransom Richardson ransomr@REDACTED
Tue Mar 20 22:52:19 CET 2012


When running an eunit test that causes the code under test to thrown an exception there doesn't seem to be a stack trace, which can make it hard to debug. I wrote the following macros which I can put around my test code to output the stack trace, but I was wondering if there is an easier or better way to do this.

Is there a reason that EUnit doesn't output the stacktrace on failures?

-define(TEST_START, try ok).
-define(TEST_END,
                ok
                catch
                    Type:X ->
                                io:format("~p~n", [{Type, X, erlang:get_stacktrace()}]),
                                ?assert(unhandled_exception)
                end).

some_eunit_test() ->
    ?TEST_START,
    ?assert(...),
    ?TEST_END.

Thanks,
Ransom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120320/67ac42c6/attachment.htm>


More information about the erlang-questions mailing list