Shorter feedback loops with Elixir tests
In Ruby, you have the --fail-fast
flag, which stops running the test suite at the first failed test. Convenient to get shorter feedback loops, with a long running test suite.
In Elixir, you can achieve the same with:
mix test --max-failures 1
And then when a test fails, you fix it, and make sure that it works with:
mix test --failed
That makes for shorter feedback loops!
Test selection with Zig
With Zig, I usually run zig build test
to run all the tests. However, sometimes, I need to run a single test, and that option is not available through the build
command.
In this case, I learned you can use the zig test
command along with the --test-filter
option.
For example, to test a single test named “lexer initialization” located in src/lexer/lexer.zig
, you can run zig test --test-filter “lexer initialization” src/lexer/lexer.zig
. It’s worth noting that the test filter doesn’t have to be the full name of the test to be able to find it.