[erlang-questions] eunit setup and cleanup

Filippo Pacini pacini@REDACTED
Fri Sep 7 15:16:04 CEST 2007


Thanks Vlad,
now it works.

As you found I had a typo and I hadn't noticed the error compiling in
emacs :-(

filippo

Vlad Dumitrescu wrote:
> Hi,
> 
> On 9/7/07, *Filippo Pacini* <pacini@REDACTED
> <mailto:pacini@REDACTED>> wrote:
> 
> 
>     -module(eunit_simple).
>     -include_lib("eunit/include/eunit.hrl").
> 
>     setup() ->
>         io:format("Setup called", []).
> 
>     do_test_() ->
>        {setup, fun setup_test/0, [?_assert(1=:=0)]}. 
> 
> 
> I suppose you meant
>          {setup, fun setup/0, [?_assert(1=:=0)]}.
> 
> The problem is that the output of io:format goes to the test process'
> group_leader, which in normal cases is printing it to the console, but
> in this case the eunit framework replaces it so that the output can be
> handled by test's parent, if necessary.
> 
> Try replacing it with erlang:display("Setup called") and you will see
> the message as expected.
> 
> BTW your test should fail, so make sure that if you make changes you
> reload it after recompiling before re-running the tests.
> 
> best regards,
> Vlad
> 



More information about the erlang-questions mailing list