Index

Table of contents

bats

install
sudo apt install bats
running tests
bats [file]

syntax

bats file header (interpreter directive)
#!/usr/bin/env bats
simple test case testing script output
@test "verify script output" {
  result="$(sh [script] [args])"
  [ "$result" = "[expectation]" ]
}
test for exit code and message
@test "verify exit code and message" {
  run sh [script] [args]
  [ "$status" -eq 1 ]
  [ "$output" = "[expectation]" ]
}

documentation

https://github.com/sstephenson/bats