There are 5 ways to run only specific tests with Elixir
-
run a single file with
mix test path_to_your_tests/your_test_file.exs
This will run all test defined inyour_test_file.exs -
run a specific test from a specific test file by adding a colon and the line number of that test
for examplemix test path_to_your_tests/your_test_file.exs:12will run the test at line 12 of
your_test_file.exs -
define a tag to exclude on your test methods
defmodule MyTests do @tag disabled: true test "some test" do #testtesttest end endon the command line execute your tests like this
mix test --exclude disabled -
define a tag to include on your test methods
defmodule MyTests do @tag mustexec: true test "some test" do #testtesttest end endon the command line execute your tests like this
mix test --only mustexec -
Generally exclude some tagged tests by adding this to your
test/test_helper.exsfile
ExUnit.configure exclude: [disabled: true]
Warning:
Mix has an --include directive. This directive is NOT the same as the --only directive. Include is used to break the general configuration (exclusion) from the test/test_helper.exsfile described under 4).
For some reason googling for elixir mix include testsor the like never shows up on my search results therefore I have written this entry and its answer. For more info, see the Mix documentation.