Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Elixir's ExUnit, is it possible to just run one test?

Tags:

elixir

In Python's nosetests you can just specify to run one test by calling its class followed by the test name. How can we do this with Elixir's ExUnit?

like image 797
Muhammad Lukman Low Avatar asked Feb 19 '14 10:02

Muhammad Lukman Low


3 Answers

You can now do mix test path/to/test.exs:13, where 13 is the line of the test.

like image 68
José Valim Avatar answered Nov 11 '22 04:11

José Valim


Add a tag to a test (e.g. wip) and run with the mix --only flag.

@tag :wip
test "only run this test" do
  assert true
end

Run as: mix test --only wip

This will only run tests with the defined tag, skipping all others.

like image 26
Ben Smith Avatar answered Nov 11 '22 03:11

Ben Smith


I asked the same question today on IRC and the guys answered (thanks Nhu and José) that now I can do it with mix.

You can run a single test with:

mix test path/to/file_test.exs:42

If you work with Vim, you can create a mapping like I did here (based on vim-rspec).

like image 15
Philip Sampaio Avatar answered Nov 11 '22 03:11

Philip Sampaio