[erlang-questions] eunit setup and cleanup

Vlad Dumitrescu vladdu55@REDACTED
Fri Sep 7 13:25:08 CEST 2007


Hi,

On 9/7/07, Filippo Pacini <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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070907/951ee06f/attachment.htm>


More information about the erlang-questions mailing list