r00takaspin

r00takaspin

How to rerun only failed tests?

Is it any similar to mix test --failed?

Most Liked

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.

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

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.

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.

sorentwo

sorentwo

Oban Core Team

Sorry, I should have been clearer. It has hit master, but it hasn’t been released. I believe it is targeted at the 1.7 release. Then again, I had nothing to do with the PR and don’t plan the releases, so take that cum grano salis.

Where Next?

Popular in Questions Top

freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
gazoon
I want to know absolute current module path. In python i could do that: os.path.abspath(__file__) Does elixir have anything similar?
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

Other popular topics Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

We're in Beta

About us Mission Statement