You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(mix test) add test_load_pattern and test_warn_pattern
When using the default project configuration, mix test would only warn
about files ending in `_test.ex`. The only mistake this warns about is
forgetting the `s` of `.exs`. In a work project we noticed (after more
than a year) that we had multiple test files that did not match the test
pattern, preventing them from running in mix test locally and CI.
Because we have many other tests, nobody noticed this. If CI passes, all
is good, right?
Because there is no easy way to evaluate glob patterns in Elixir without
touching the filesystem, I decided to deprecate the old configurations
and instead add two new configurations: `test_load_pattern` and
`test_warn_pattern`. Now, we can load all potential test files once and
then match their paths to the patterns.
The `test_load_pattern` is used to filter the files that are loaded by
mix test. This defaults to the regex equivalent of "*_test.exs". The
`test_warn_pattern` is used to filter the files that we warned about if
they are not loaded. By default, we warn about any file that either ends
in `_test.ex` (the old behavior) but also any file that ends in `.exs`,
but does not end in `_helper.exs`, which will prevent the default
test_helper.exs from generating a warning and also provides a way to name
other files that might be required explicitly in tests. As an escape hatch
the `test_warn_ignore_files` list can be used to ignore specific files
where the warning should not be generated.
For projects with an existing `warn_test_pattern` configuration,
a deprecation warning is logged. The new warnings can be disabled by
setting `test_warn_pattern` to a falsy value.
Projects with an existing custom `test_pattern` should check if their
pattern conflicts with the new `test_load_pattern`.
0 commit comments