Skip to content

Commit b536a2a

Browse files
committed
Write in-depth docs on how to use filters as flags
1 parent a5602a7 commit b536a2a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lib/ex_unit/lib/ex_unit/case.ex

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,37 @@ defmodule ExUnit.Case do
110110
* `:test` - the test name
111111
* `:line` - the line the test was defined
112112
113+
## Filters
114+
115+
Tags can also be used to identify specific tests, which can then be included
116+
or excluded using filters. Filters are defined as key-value pairs, similar to
117+
tags, and are used to match against the tags given for each test. For example
118+
the following command will skip any test that contains the `:os` tag but has
119+
a value other than `"unix"`.
120+
121+
mix test --include os:unix
122+
123+
If your tags are defined using boolean values, you can use the shorthand
124+
version by only specifying the tag name. The value will be automatically set
125+
to `true`. To skip all tests with a tag of `slow: true` run the following
126+
command:
127+
128+
mix test --exclude slow
129+
130+
Filters can also be combined to further limit the tests to be run. When
131+
defining filters with the same tag name, tests that match either filter will
132+
be run. The following command will skip any test that contains the `:os` tag
133+
but has a value other than `"unix"` or `"win32"`:
134+
135+
mix test --include os:unix --include os:win32
136+
137+
However, if multiple filters with different tag names are given, only tests
138+
that match the filter defined for each unique tag name will be run. This
139+
command will only run tests that have both `os: "unix"` and `type: "unit"`
140+
tags.
141+
142+
mix test --include os:unix --include type:unit
143+
113144
"""
114145

115146
@doc false

0 commit comments

Comments
 (0)