Search⌘ K
AI Features

Write Some Basic Tests

Explore how to write basic tests in Elixir using the built-in ExUnit testing framework. Learn to create test modules, use assertions to validate code, interpret test failures, and run tests with mix test. Understand testing CLI options and handling common errors to improve your Elixir project organization.

We'll cover the following...

Elixir comes with a wonderful and simple testing framework called ExUnit.

Have a look at this code:

defmodule IssuesTest do
  use ExUnit.Case
  doctest Issues

  test "greets the world" do
    assert Issues.hello() == :world
  end
end

It acts as a template for all the test files we write. We just copy and paste the boilerplate into separate test files as we need them. So, let’s write tests for our CLI module, putting those tests into the file ...