[ExUnit] Nested describe Support or Improve Multi-Line test message

53 views
Skip to first unread message

Yordis Prieto

unread,
Apr 10, 2022, 4:41:46 PM4/10/22
to elixir-lang-core
Proposal
- Allow nested `describe/2` blocks (or)
- Improve multi-line text as messages.

Context
Recently, I am trying to stick to BDD-driven text by discipline alone (no magical framework), so the test message would be written in a "given ... when ... then ..." format, for example:

```
defmodule Testing do
use ExUnit.Case, async: false
test """
given some context
when something happens
then expect x to happen
""" do
assert true
end
end
```
```
 mix test test/testing_test.exs

Testing [test/testing_test.exs]
  * test given some context
when something happens
then expect x
  * test given some context
when something happens
then expect x
```
Screen Shot 2022-04-10 at 4.25.39 PM.png

The output of that is suboptimal, notice the spacing is a bit off.

`describe/2` could be used to remove some of the multi-line statements, `describe/2` solves the issue of the spacing.
But I can not use nested `describe/2` calls so I can't take advantage of it. Also, I never understood or ask why wasn't supported before.

Using a single line will make the message long enough that people are discouraged from writing human-readable texts. and having to scroll horizontally to fully read the message.
This is why I would like the mult-line text to be taken into consideration and maybe add the padding or something ... to improve the text output.


Reply all
Reply to author
Forward
0 new messages