ExUnit and focused test runs
Create test configurations, navigate failures, and control the test environment.
On this page
Start with one test#
Use this test in the downloadable workshop:
defmodule OrderWorkshopTest do
use ExUnit.Case
test "quotes a multi-item order" do
assert OrderWorkshop.Checkout.quote_order(125, 3) == 375
end
end
Run the gutter action beside the test. Compare it with the action for the whole module/file so you know which scope is executing. The native test tree provides individual results, source navigation, timings, and rerunning failed tests.
Configure an explicit run#
Create a mix test configuration under Run → Edit Configurations. Select the Mix working directory, Elixir SDK, test scope, arguments, and environment. In a large application, start with one file or test location rather than running an umbrella’s entire suite while diagnosing setup.
The equivalent command-line shape is:
mix test test/order_workshop_test.exs
mix test test/order_workshop_test.exs:5
The line filter must point at the intended test in your local file. Added comments or imports change line numbers.
Understand a failure#
Change 375 to 376 and rerun. Select the failed node and follow its assertion location. Confirm whether the failure is an assertion, compilation error, timeout, or failure before tests started. Those are different problems even if all make the configuration red.
Use rerun-failed only after the initial test set is known. If test selection changes, run the intended file again to ensure you are not reviewing an older subset.
Match the real test environment#
Check MIX_ENV, explicit variables, project root, dependencies, and services expected by the test suite. Plugin test integration does not start a database merely because the test needs one. For a failure seen only in the IDE, compare the generated command and selected SDK with a terminal run.
Manual for version 2026.1.15 · Reviewed