bats-testinglisted
Install: claude install-skill testland/qa
# bats-testing
## Overview
Per [bats-readthedocs][bats]:
[bats]: https://bats-core.readthedocs.io/en/stable/
> "Bats (Bash Automated Testing System) is a TAP-compliant testing
> framework for Bash 3.2 or above."
Per [bats-github][bgh]:
[bgh]: https://github.com/bats-core/bats-core
> "Bats is a TAP-compliant testing framework for Bash 3.2 or above.
> It provides a simple way to verify that the UNIX programs you
> write behave as expected."
Bats works "with any Unix program," not just Bash - it captures
stdout / stderr / exit code of any executable.
## When to use
- Testing a shell script (deployment scripts, CI scripts,
installers).
- Testing a CLI binary's interface (commands, flags, exit codes,
output) at the integration layer.
- Validating that wrapper scripts (e.g., `kubectl` plugins, `git`
aliases) behave as expected.
- Cross-platform smoke tests for a CLI's install scripts.
## How to use
1. Install `bats` (npm / Homebrew / git submodule); pin via submodule for CI determinism (Step 1).
2. Create `test/<feature>.bats` starting with `#!/usr/bin/env bats` and one `@test` block per behavior (Step 2).
3. Wrap each command under test with `run`, then assert on `$status`, `$output`, and `$lines[]` (Step 3).
4. Add `setup` / `teardown` with `mktemp -d` so each test is isolated and parallel-safe (Step 4).
5. `load` shared helpers plus bats-support / bats-assert for diff-style assertions (Steps 5-6).
6. Guard environment-specific tests with `skip`; run the suite v