Test Shell Scripts With Bats
Write readable bash test cases with assertions and run them from the CLI.
Run bats tests/ to execute every .bats test file in a directory.
01Command
Command
$ bats tests/02What it does
Bats (Bash Automated Testing System) provides a small DSL for testing shell code: setup and teardown hooks, run to capture output and status, and assertions. It outputs TAP and integrates with CI, bringing test discipline to shell projects.
03Risk
!Warning: Tests run with the invoking user's privileges and can execute arbitrary commands; treat test files as code to review.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Bats documentationEvidence: Debian packages Bats, a TAP-compliant testing framework for Bash.
- Debian package: batsEvidence: Debian packages Bats, a TAP-compliant testing framework for Bash.
Last verified: 2026-09-22 · Category: Developer