shpec
Test your shell scripts
This package provides a command for testing your shell scripts.
Using shpec
shpec’s repo itself is using shpec, so feel free to use it as an example.
Here is the basic structure that you’ll want:
└── shpec
└── an_example_shpec.sh
└── another_shpec.sh
Then to run your tests:
If you’d like your tests to run automatically when they change, we recommend the entr utility:
Examples
shpec’s own tests are a great place to start. For more examples, see the wiki page
Matchers
The general format is:
assert matcher arguments
where matcher
is one of the following:
Binary Matchers
Unary Matchers
Custom Matchers
Custom matchers are loaded from shpec/matchers/*.sh
.
For example, here’s how you’d create a still_alive
matcher:
Then you can use that matcher like any other:
Installation
You can either install with bpkg
or with curl
or with antigen for zsh by
putting antigen bundle rylnd/shpec
in your .zshrc
Links
- Source Code (GitHub)
- Author: Ryland Herrick
blog comments powered by Disqus