This is not my work, but the author (same author as zsh-abbr) posted it elsewhere and it looks good to me.
In his words:
What is zsh-test-runner? A simple testing framework for zsh, and to a degree —thanks to zsh's emulation of other shells— csh, ksh, and sh.
The immediately noticeable difference between zsh-test-runner and other shell script unit test frameworks is it doesn't have a DSL. zsh-test-runner relies entirely on the shell's own testing. For those familiar with other frameworks: nothing like ShellSpec's
Describe … When call … The output should
, or shUnit2'sassertEquals
, or ZUnit'sassert
; zsh-test-runner is closer to Bats if you were to restrict yourself to core and not use helper libraries (there's nothing like bats-assert'sassertEquals
or bats-file'sassert_dir_exists
).
Why no special syntax? It means there's little new to learn— For example, if you know how to test numeric equality in your shell, you know how to test equality in zsh-test-runner; if you don't, there are community resources available. It means every possible test is supported equally out of the box— zsh-test-runner is a newcomer, but there are no "shoot my assertion method isn't supported" blockers. It means the cost of porting homegrow framework-less tests to zsh-test-runner is about as low as can be— generally speaking,
my_cool_test_code
becomesztr test 'my_cool_test_code'
. It means tests can live comfortably in one LOC, making zsh-test-runner pleasant to use in the terminal.