Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Abort ExUnit on the first test that does not pass

In Ruby, specifically RSpec, you can tell the test runner to abort on the first test that does not pass by the command-line flag --fail-fast. This helps a lot to not waste time or lose focus when fixing a lot of test in a row, for example when doing test-driven or behavior-driven development.

Now on Elixir with ExUnit I am looking for a way to do exactly that. Is there a way to do this?

like image 429
aef Avatar asked May 23 '18 12:05

aef


2 Answers

There is such an option since Elixir 1.8.

Use the --max-failures switch to limit the number of tests evaluated with failure. To halt the test suite after the first failure, run this:

mix test --max-failures 1
like image 91
Nic Nilov Avatar answered Oct 15 '22 13:10

Nic Nilov


Unfortunately there is (to my knowledge) no such flag implemented.

However, you can run a single test by

mix test path/to/testfile.exs:12

where 12 is the line number of the test.

Hope that helps!

like image 20
jfornoff Avatar answered Oct 15 '22 13:10

jfornoff