home / testing / bats

bats

5.9k

Bash test runner for `.bats` files that verify shell scripts and other Unix commands.

$brew install bats-core
Language
Shell
Stars
5,867
Category
Testing & QA
Agent
AI Analysis

Bats is a Bash test runner for .bats files that wrap shell commands in a TAP-oriented test harness. It is mainly a verification tool for Bash scripts and other Unix command-line behavior.

What It Enables
  • Run repeatable shell test suites that assert command exit codes, stdout and stderr, and line-by-line output.
  • Target only the tests you need with file or directory runs, recursive discovery, regex filters, tag filters, or reruns based on last failure status.
  • Feed results into CI or agent verify loops with TAP or TAP13 output and optional JUnit report files.
Agent Fit
  • Exit codes are simple and dependable: 0 when every test passes and 1 when any test fails.
  • Non-interactive flags and machine-readable TAP or JUnit outputs work well in scripts, but there is no native JSON output.
  • Best fit is shell-heavy projects where an agent needs to verify behavior after edits rather than control external services directly.
Caveats
  • You only get value once meaningful .bats tests exist; the CLI is a runner, not a test generator.
  • Parallel execution requires GNU parallel or a compatible replacement such as rush.