Summary
Per FlossWare org standard, all shell scripts must have BATS (Bash Automated Testing System) tests — even a single script or function gets a test.
What to do
- Add BATS as a dev dependency
- Create a
tests/bats/ directory (or tests/ if no other test framework)
- Write
.bats test files for every .sh script and shell function
- Add BATS to CI (GitHub Actions)
Shell scripts in this repo
9 shell scripts found.
BATS setup
# Install
git clone https://github.com/bats-core/bats-core.git
cd bats-core && sudo ./install.sh /usr/local
# Helper libraries (recommended)
git clone https://github.com/bats-core/bats-support.git test/test_helper/bats-support
git clone https://github.com/bats-core/bats-assert.git test/test_helper/bats-assert
Example test
#!/usr/bin/env bats
@test "script runs without error" {
run ./my-script.sh --help
[ "$status" -eq 0 ]
}
@test "output contains expected string" {
run ./my-script.sh
[[ "$output" == *"expected"* ]]
}
Rule
FlossWare org standard: every shell script gets BATS tests, no exceptions.
Summary
Per FlossWare org standard, all shell scripts must have BATS (Bash Automated Testing System) tests — even a single script or function gets a test.
What to do
tests/bats/directory (ortests/if no other test framework).batstest files for every.shscript and shell functionShell scripts in this repo
9 shell scripts found.
BATS setup
Example test
Rule
FlossWare org standard: every shell script gets BATS tests, no exceptions.