r00takaspin

r00takaspin

How to rerun only failed tests?

Is it any similar to mix test --failed?

First Post!

NobbZ

NobbZ

There is no such a thing.

But you can use mix test --stale to run all tests that depend on your changed code.

In case of failures all tests that were run in the last run will be repeated until you get a successfull run.

Most Liked

tmpduarte

tmpduarte

Probably a bit late to the party :smiley: .

You can now run only the previously failed tests by running mix test --failed
Documentation can be found here

sorentwo

sorentwo

Oban Core Team

This exact feature was added a few weeks ago. In fact, it was added by Myron Marston (who had implemented the behavior in rspec originally).

Here is the PR for the second half https://github.com/elixir-lang/elixir/pull/7373, it is an awesome demonstration of open source collaboration.

eahanson

eahanson

I do this with a custom test formatter (a copy of ExUnit.CLIFormatter) that saves the filenames of the failed tests in the handle_cast function that deals with test failures.

You can get the failed test file and line number from that function by pattern matching:

  def handle_cast({:test_finished, %ExUnit.Test{tags: %{file: file, line: line}, state: {:failed, failures}} = test}, config) do

I add those to the config, and then in print_suite I read them out of the config and save them to a file.

I then have a mix task called retest that runs mix test with the contents of that file as arguments. Note that when passing multiple test files to mix test, you cannot include line numbers (at least in Elixir 1.5).

Then, when I have failures, I just run retest over and over until I’ve fixed all the failures.

Where Next?

Popular in Questions Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

Other popular topics Top

sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement