[erlang-questions] Eunit error messages

7 views
Skip to first unread message

Rick Moynihan

unread,
Aug 18, 2010, 8:06:53 AM8/18/10
to erlang-q...@erlang.org
Hi all,

I've been using EUnit to do some unit testing; and it seems to work quite well.

However, I'm having a couple of problems, mostly down to the
legibility of error reports. In unit testing frameworks I've used in
the past the assertion functions all took a string to provide a human
readable description of what the error was, am I right in thinking
EUnit doesn't support this? If so, what's the best way to replicate
this behaviour, I've been manually adding debugMsg's but that's a bit
messy as I also need to throw an exception to indicate failure.

Any tips gratefully received,

R.

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-questio...@erlang.org

Magnus Henoch

unread,
Aug 18, 2010, 8:39:07 AM8/18/10
to erlang-q...@erlang.org
Rick Moynihan <ri...@wgrids.com> writes:

> I've been using EUnit to do some unit testing; and it seems to work quite well.
>
> However, I'm having a couple of problems, mostly down to the
> legibility of error reports. In unit testing frameworks I've used in
> the past the assertion functions all took a string to provide a human
> readable description of what the error was, am I right in thinking
> EUnit doesn't support this? If so, what's the best way to replicate
> this behaviour, I've been manually adding debugMsg's but that's a bit
> messy as I also need to throw an exception to indicate failure.

You can label your tests, as long as they are in EUnit's test
representation:

foo_test_() ->
{"Testing whether foo is bar",
?_test(foo = bar)}.

This gives:

1> foo:test().
foo:7: foo_test_ (Testing whether foo is bar)...*failed*
::error:{badmatch,bar}
in function foo:'-foo_test_/0-fun-0-'/0


=======================================================
Failed: 1. Skipped: 0. Passed: 0.
error

Is that what you're looking for?

Magnus

Reply all
Reply to author
Forward
0 new messages