Learn how to write automated tests using Elixir's built-in ExUnit testing framework
Learn how to write automated tests using Elixir’s built-in ExUnit testing framework.
mix test
test/
directorymix test
to execute all tests, or specify a file or line to run just those testsdefmodule ...Test
and use ExUnit.Case
test "description" do ... end
macroassert
for checking expectations; refute
for negating themmix.exs
for consistent workflowasync: false
)use
macrouse ExUnit.Case, async: true
sets up the test environmentdoctest
macro lets you write tests in your docs (@doc
), and runs them automaticallysetup
and setup_all
for test prep, sharing state/context among multiple testsmix test --cover
to see which lines of code are testedExUnit is Elixir’s slick, parallel, and repeatable unit/integration testing tool. It offers clear syntax, per-file and per-test targeting, helpful macros (doctest
, assert
, setup
), and keeps your codebase robust, maintainable, and well-documented.