ExUnit: improved error messages

31 views
Skip to first unread message

eksperimental

unread,
Sep 9, 2015, 1:20:02 AM9/9/15
to elixir-l...@googlegroups.com
While doing various fixes in Elixir, I have come across two issues at
once,
(attached is a copy of the terminal output for easier reading)

1) test prints elixir req mismatches (Mix.Tasks.DepsTest)
test/mix/tasks/deps_test.exs:75
No message matching {:mix_shell, :error, [^msg]} after 0ms.
Process mailbox: {:mix_shell, :info, ["==> ok"]}
{:mix_shell, :error, ["warning: the dependency 'ok' requires
Elixir \"~> 0.1.0\" but you are running on v1.1.0-beta"]}
{:mix_shell, :info, ["Generated ok app"]} stacktrace:
test/mix/tasks/deps_test.exs:93: anonymous fn/0 in
Mix.Tasks.DepsTest.test prints elixir req mismatches/1 (elixir)
lib/file.ex:1131: File.cd!/2 test/test_helper.exs:102:
MixTest.Case.in_fixture/3 test/mix/tasks/deps_test.exs:78


the code in the test setting this up:
msg = "warning: the dependency 'ok' requires Elixir \"~> 0.1.0\"
" <> "but you are running on v#{System.version}"
assert_received {:mix_shell, :error, [^msg]}

What I'm missing the Expected value, which made me impossible to
realize, without going back to the source code, to see what was wrong
with it.

*******

The second issue is,

```
2) test cleans dependencies (Mix.Tasks.DepsTest)
test/mix/tasks/deps_test.exs:570
Wrong message for Mix.Error. Expected "mix deps.clean expects
dependencies as arguments or a flag indicating which dependencies
to clean. The --all option will clean all dependencies while the
--unused option cleans unused dependencies", got "`mix deps.clean`
expects dependencies as arguments or a flag indicating which
dependencies to clean. The '--all' option will clean all
dependencies while the '--unused' option cleans unused
dependencies"
```

Wouldn't it be much clearer to have something broken into new lines
such as,


Wrong message for Mix.Error.
Expected:
"mix deps.clean expects dependencies as arguments or a flag
indicating which dependencies to clean. The --all option will
clean all dependencies while the --unused option cleans unused
dependencies"
Got:
"`mix deps.clean` expects dependencies as
arguments or a flag indicating which dependencies to clean. The
'--all' option will clean all dependencies while the '--unused'
option cleans unused dependencies"

thanks for reading
ex_unit_error_msg.txt

José Valim

unread,
Sep 9, 2015, 2:17:58 AM9/9/15
to elixir-l...@googlegroups.com
Yes, defintiely. Please open up issues. :)



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


--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/20150909121951.44e87d74.eksperimental%40autistici.org.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages