%{ title: "Tests in Elixir", author: "Luiz Cattani", tags: ~w(tests elixir), description: "Testing in Elixir" }
Tool default in Elixir language to test our code
Elixir supports the ability to run tests concurrently within the same Elixir instance.
Run all specs
$ mix test
Run a specific spec
$ mix test test/hello_world_test.exs
We can create tags for our specs
@tag :simple_test
test "does not greets the world" do
assert HelloWorld.hello() == :world
end
Run the specs with a specific tag
$ mix test --only tag_name
Run all tests excluding a specific tag
$ mix test --exclude tag_name
if a duplicated describe of a spec exists in the same file Elixir raise an error, awesome \o/
test "does not greets the world" do
refute HelloWorld.hello() == :wolrd
end
test "does not greets the world" do
assert HelloWorld.hello() == :world
end
$ mix test
(ExUnit.DuplicateTestError) "test does not greets the world" is already defined in HelloWorldTest