Today I Learned

hashrocket A Hashrocket project

Run ExUnit tests in the order they are defined

You might have a test module like this.

ExUnit.start

defmodule TestOrderTest do
  use ExUnit.Case

  test "first" do
    assert true
  end

  test "second" do
    assert true
  end
end

And when you run it, second runs before first!

In general this is fine, because every test should pass no matter which one runs first. In certain circumstances however, lets say you're working through some Exercism.io challenges, you might want them to run in order.

To do so include the configuration seed: 0

Elixir.configure seed: 0

And tackle every test in the order they've been given to you!

See More #elixir TILs
Looking for help? At Hashrocket, we 💜 Elixir! From our many Elixir client projects, to sponsoring the Chicago Elixir Meetup, to the source code for this application, we are invested in this community. Contact us today to talk about your Elixir project.