ExUnit unwanted output

609 views
Skip to first unread message

Elliot Crosby-McCullough

unread,
May 23, 2016, 2:01:50 PM5/23/16
to elixir-l...@googlegroups.com
Hello!

I'm testing some GenServers, specifically testing certain behaviours that deliberately cause the GenServer to terminate itself.

This is all going well, except the test run outputs a notification about the closing process (the GenServer, not the test process) on what I assume is STDERR.  Is there some way to suppress this?

It seems to happen whether I start the genserver via `start_link` and unlink it or create one without linking.

All the best,
Elliot

Louis Pilfold

unread,
May 23, 2016, 3:09:10 PM5/23/16
to elixir-lang-talk
Hey Elliot

Could you share the printed notification with us please?

Cheers,
Louis
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elixir-lang-ta...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-talk/CAD2T2cju977Dm8rC_dgfDaTHacOSGvhryXwgmUZZn1k5vADPww%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

José Valim

unread,
May 23, 2016, 3:18:34 PM5/23/16
to elixir-l...@googlegroups.com
Just use the capture log tag to, well, capture the log:

@tag :capture_log
test "this test will log error stuff" do

You can also set it for the whole suite: ExUnit.start(capture_log: true). If you do so, the log will still be included in error reports.




José Valim
Skype: jv.ptec
Founder and Director of R&D

Elliot Crosby-McCullough

unread,
May 24, 2016, 2:48:33 AM5/24/16
to elixir-lang-talk, jose....@plataformatec.com.br
That did the job, thanks José.  I'd already tried using ExUnit.CaptureIO to no effect, didn't know this tag existed.

Louis, in case you'd still like to know, this was the log output:

07:43:21.560 [error] GenServer #PID<0.99.0> terminating
** (stop) "Closing connection"
Last message: {.. bunch of stuff ..}
State: {%{connection_abort: #Function<3.107869130/1 in ZeroMQ.ConnectionTest.__ex_unit_setup_0/1>, message_delivery: #Function<1.107869130/1 in ZeroMQ.ConnectionTest.__ex_unit_setup_0/1>, peer_delivery: #Function<2.107869130/1 in ZeroMQ.ConnectionTest.__ex_unit_setup_0/1>, security_mechanism: #Function<5.107869130/1 in ZeroMQ.ConnectionTest.__ex_unit_setup_0/1>}, #PID<0.100.0>, {.. closing state ..}}

Thanks both,
Elliot
Reply all
Reply to author
Forward
0 new messages