Shellspec
I picked shellspec without too much research or experience, so don’t really know how it compares to shUnit2 etc.
A snag is (at time of writing) it’s not included in Arch Linux’s pacman list, so needs to be manually installed.
This involves:
git clone https://github.com/shellspec/shellspec.git
cd shellspec
ln -s shellspec /usr/local/bin
Shellspec is a behavior-driven development (BDD) framework, broadly following its Given-When-Then syntax.
These tests are grouped in blocks using a choice of three synonymous keywords, and each test can start with one of three synomymous keywords.
Outer blocks (Describe and Context are aliases for ExampleGroup)
- Context
- Describe
- ExampleGroup
Inner blocks (It and Specify are aliases for Example)
- It
- Specify
- Example
Since I like example-driven development (ie examples double as documentation), I favour:
ExampleGroup 'my group of examples'
Example 'first example'
# Given is not a shellspec keyword
When...
# Then is not a shellspec keyword
End
End
Given
Shellspec doesn’t use given, but does have Data to set the starting state.
When
- https://github.com/shellspec/shellspec?tab=readme-ov-file#when---evaluation
- https://github.com/shellspec/shellspec/blob/master/docs/references.md#evaluation
Then
Shellspec uses The instead of then followed by modifiers and matchers.