ExUnit test descriptions

Two things I like:

Getting things done.

Attention to detail.

I have been writing a fair few tests recently for various phoenix projects using describe blocks. I started using describe blocks mostly as a connivence to run certain setup functions for a given describe block…

defmodule Foo.BarTest do
use Foo.ConnCase
describe "A broad description of the tests"
setup [
:start_api,
:default_fixture,
:custom_fixtures
]
test "something specific that should be a 302" do
# build a response
resp = build_conn() |> post("/foo", %{bar: "baz"})
# it was a 302
assert 302 == resp.status_code
end
end
end

What was not apparent to me was the way that when the tests fail, the string from the top of the description block and the test is concatenated. So when a test fails I noticed this