bats

noun

say it: “BATS” /ˈbæts/

A program that runs tests written in bash and marks each one as passed or failed.

What is bats?

bats runs tests written in bash. Each @test block runs your script with run, which saves its exit code in $status and what it printed in $output, then checks them. bats mover.bats prints a ✓ for each test that passed and a ✗ for each that failed, with the line that failed.

@test "with no folders, it shows how to use it" {
  run "$mover"
  [[ "$status" -eq 2 ]]
  [[ "$output" == "Usage: mover.sh FROM-FOLDER TO-FOLDER" ]]
}
# bats mover.bats  prints  ✓ with no folders, it shows how to use it

In a sentence

  • “The exercises in this course are checked with bats.”
  • “bats mover.bats printed three check marks: all three tests passed.”

Level: Freelancer · More Unix terms at this level

Updated