Frontier Software

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.

G i v e n W h e n T h e n

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)

Inner blocks (It and Specify are aliases for 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

Then

Shellspec uses The instead of then followed by modifiers and matchers.