eunit status messages

Magnus Henoch <>
Wed Sep 22 14:38:57 CEST 2010


Vlad Dumitrescu <> writes:

> I checked the eunit code and want to make sure that I didn't miss
> anything: when starting a test run, there is an undocumented option
> 'report' that should allow to register a process to receive status
> messages. I tried it but I get strange bahaviour, maybe I'm doing
> something wrong?
>
> 1> eunit:test(mod, [{report, self()}]).
>   Test passed.
> ok
> 2> receive X->X after 5 -> nothing end.
> {start,#Ref<0.0.0.67>}
> 6> receive X->X after 5 -> nothing end.
> nothing
> 7> eunit:test(mod, [{report, self()}]).
>   Test passed.
> ok
> 8> receive X->X after 5 -> nothing end.
> nothing
>
> It works the first time, but not afterwards. Also I would have
> expected to see the status messages defined in eunit_proc...

You're using the variable X more than once, so you're not seeing the
messages as they are not identical to the first one.

You can use the shell function flush() to print messages received by the
shell:

Eshell V5.7.5  (abort with ^G)
1> eunit:test(fun() -> ok end, [{report, self()}]).
  Test passed.
ok
2> flush().
Shell got {start,#Ref<0.0.0.30>}
Shell got {status,[],
                  {progress,'begin',
                            {group,[{desc,undefined},
                                    {spawn,undefined},
                                    {order,undefined}]}}}
Shell got {status,[1],
                  {progress,'begin',
                            {test,[{desc,undefined},
                                   {source,{erl_eval,expr,5}},
                                   {line,0}]}}}
Shell got {status,[1],{progress,'end',{ok,[{time,6},{output,<<>>}]}}}
Shell got {status,[],{progress,'end',{1,[{time,21},{output,<<>>}]}}}
Shell got {stop,#Ref<0.0.0.30>,<0.33.0>}
ok

-- 
Magnus Henoch, 
  Erlang Solutions
  http://www.erlang-solutions.com/


More information about the erlang-questions mailing list