Install entr:
https://github.com/clibs/entr
Add this to .bashrc
elixir_test() {
if [[ $# -eq 0 ]] ; then
find . -name '*.ex' -o \
-name '*.exs' -o \
-name '*.eex' | \
entr mix test
else
find . -name '*.ex' -o \
-name '*.exs' -o \
-name '*.eex' | \
entr mix test --include $1 --exclude test
fi
}
From command line, in an elixir project:
$ elixir_test
This will run the tests whenever file change event is detected.
For more focused testing, you can run this:
$ elixir_test focus
And update your tests like this:
describe "using entr for test driven development" do
@tag :focus
test "only this test will be run" do
assert true
end
test "this test will not be run" do
assert true
end
end
Happy coding...