Write automated tests for your Bash scripts to catch regressions before deploying to production.
Verify that command-line tools return the correct exit codes and expected output strings.
Integrate shell script tests into a CI pipeline using TAP-format output that standard test reporters understand.
This repo is no longer maintained, use the community bats-core fork for continued development.
Bats stands for Bash Automated Testing System. It is a testing framework for shell scripts, specifically for the Bash shell that is standard on Linux and macOS. Its purpose is to help developers verify that their command-line programs and Bash scripts behave correctly, in the same way that testing libraries exist for languages like Python or JavaScript. A Bats test file is a plain Bash script with a special @test block syntax. Each block has a description and contains shell commands. If every command in a test block exits successfully, the test passes. If any command fails, the test is marked as failing. This design means that writing tests requires no new language to learn beyond what you already know about shell scripting. Bats provides a few built-in helpers to make common testing patterns easier. The run helper lets you execute a command and then check its exit code and output separately. The load helper lets you share setup code across multiple test files. The skip command lets you mark a test as temporarily bypassed, optionally with a reason. You can also define setup and teardown functions that run before and after each test case to prepare and clean up the environment. Running tests is straightforward: pass a file or folder to the bats command, and it prints a summary showing which tests passed and which failed. When run in automated systems like CI pipelines, it outputs results in TAP format, a plain-text standard that many test reporting tools understand. Installation is a clone-and-run process with no package dependencies. The project is no longer actively maintained in this original repository, but a community-maintained fork named bats-core has taken over continued development.
← sstephenson on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.