Bats

From wikinotes

A test framework for bash.

Documentation

github https://github.com/bats-core/bats-core
official docs https://github.com/bats-core/bats-core/tree/master/docs/source

Install

sudo pacman -S \
  bash-bats \
  bash-bats-assert \
  bash-bats-support

Usage

bats foo_test.bats

Syntax

#!/usr/bin/env bats

@test "addition using bc" {
  result="$(echo 2+2 | bc)"
  [ "$result" -eq 4 ]
}