Today I Learned

A Hashrocket project

Run ExUnit tests in the order they are defined

You might have a test module like this.


defmodule TestOrderTest do
  use ExUnit.Case

  test "first" do
    assert true

  test "second" do
    assert true

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 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!

Looking for help? Elixir is quickly gaining momentum for web applications that need concurrency, performance, and the ability to connect to many different clients. The developers at Hashrocket are learning along with the rest of the development community that Elixir and Phoenix are viable Rails alternatives for the right application. Check out the source code for Today I Learned, written in Elixir, and contact us if you need help with your Elixir project.