sunaku
Assertion with == failed: How to disable truncation? (limit infinity)
Hello,
How can I prevent ExUnit from truncating the left and right values in an assertion failure with “…” ellipses?
Does ExUnit have a configuration option like limit: :infinity for IO.inspect()?
1) test encode() single (EncoderTest)
test/encoder_test.exs:25
Assertion with == failed
code: assert actual == expected
left: <<87, 0, 0, 0, 2, 95, 105, 100, 0, 7, 0, 0, 0, 115, 99, 104, 101,
109, 97, 0, 2, 118, 101, 114, 115, 105, 111, 110, 0, 6, 0, 0, 0,
49, 46, 49, 46, 51, 0, 2, 103, 101, 110, 101, 114, 97, 116, 111,
114, 0, ...>>
right: <<109, 0, 0, 0, 2, 95, 105, 100, 0, 7, 0, 0, 0, 115, 99, 104, 101,
109, 97, 0, 2, 118, 101, 114, 115, 105, 111, 110, 0, 6, 0, 0, 0,
49, 46, 49, 46, 51, 0, 2, 103, 101, 110, 101, 114, 97, 116, 111,
114, 0, ...>>
stacktrace:
test/encoder_test.exs:43: (test)
Currently, I’m having to manually inspect the contents of my binary data strings with IO.inspect(limit: :infinity) so that I can see them printed in their entirety for manual visual comparison: ![]()
actual = binary1 |> IO.inspect(label: "actual", limit: :infinity)
expected = binary2 |> IO.inspect(label: "expected", limit: :infinity)
assert actual == expected
Thanks for your consideration.
Marked As Solved
devonestes
At the moment it looks like the default CLI formatter for ExUnit does not have a way to display diffs with an infinite size because it uses IO.puts/2, and that function doesn’t have all the same options that IO.inspect/3 takes. It’s totally possible to write and use a separate formatter if one wanted to do that. The docs on how to do that are here: ExUnit.Formatter — ExUnit v1.20.2
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








