67

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?

4 Answers 4

95

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

2
  • 1
    Actually now you can by added the line number of the test to the end of the above mix command
    – Dokie
    Aug 10, 2014 at 16:16
  • 7
    For umbrella project, do not include apps/app_name in the file path. Even if the file path from root directory is apps/app_name/test/app_name_test.exs, just run mix test test/app_name_test.exs:13. See this. Aug 23, 2017 at 17:41
63

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.

1
15

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).

0

It seems that Amrita can run one specific test at a time:

https://github.com/josephwilk/amrita

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.