You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is common for Elixir code to output something to the CLI. Those, however, become non-trivial to test since we don't provide a mechanism to capture IO.
Luckily, all the IO in Erlang is done via the IO protocol, which means we can replace the Erlang group leader and capture the IO. This will make it possible to test many warnings in Elixir, test IEx.Helpers and more.
This is a proposal for adding a function called capture_io/1 to ExUnit.Assertions (or maybe ExUnit.Helpers) that receives a function and while it executes the function, all the output is captured (and the input is mocked to return nothing so far):
assertcapture_io(fn->Code.eval"some code that emits a warning"end) =~ %r/gotwarning/
To implement capture_io/1, we need to take a better look at the "IO protocol". Luckily, the eunit test framework in Erlang implements it too, so we can always take a look at it for clues.
The text was updated successfully, but these errors were encountered:
It is common for Elixir code to output something to the CLI. Those, however, become non-trivial to test since we don't provide a mechanism to capture IO.
Luckily, all the IO in Erlang is done via the IO protocol, which means we can replace the Erlang group leader and capture the IO. This will make it possible to test many warnings in Elixir, test IEx.Helpers and more.
This is a proposal for adding a function called
capture_io/1
toExUnit.Assertions
(or maybeExUnit.Helpers
) that receives a function and while it executes the function, all the output is captured (and the input is mocked to return nothing so far):To implement
capture_io/1
, we need to take a better look at the "IO protocol". Luckily, the eunit test framework in Erlang implements it too, so we can always take a look at it for clues.The text was updated successfully, but these errors were encountered: