July 22, 2016
In an old post I talked about tags
in elixir and how we could use them to fake grouping of tests. See Elixir testing - Tag tests in ExUnit.
That is no longer needed.
Since 1.3 Elixir and ExUnit will let developer group tests. The syntax will be familiar to people used with rspec
. The classic describe
keyword.
Here is an example (shamelessly copied from the Elixir 1.3 Change log)
defmodule StringTest do
use ExUnit.Case, async: true
describe "String.capitalize/2" do
test "uppercases the first grapheme" do
assert "T" <> _ = String.capitalize("test")
end
test "lowercases the remaining graphemes" do
assert "Test" = String.capitalize("TEST")
end
end
end
Describes are not nestable!
See the Elixir 1.3 Change log for a complete reference of what has changed recently.
Written by Simon Ström as a way to remember. It's a dev log of thinks I want to remember.