shell-testing
Installation
SKILL.md
Shell Testing with BATS
Running Tests — Targeted Only
NEVER run the full test suite. Always run only the test files affected by the current changes.
- Map source → test file:
lib/helpers.sh→tests/helpers.bats,lib/ui.sh→tests/ui.bats,cmd/theme/*→tests/theme.bats - Run specific files:
bats tests/helpers.bats tests/theme.bats - Filter by name:
bats tests/helpers.bats --filter "format_insert" - Filter by tag:
bats tests/ --filter-tags "unit"
When multiple source files changed, run only their corresponding test files. If unsure which tests cover a function, grep for the function name across tests/*.bats.
Framework Decision
- BATS (primary): All bash code, polyglot bash/zsh code, CLI commands
- Zunit: Only for pure zsh features (completions, zle widgets, zstyle) that cannot be tested via BATS
bats --shell zsh(BATS 1.8.0+): Run BATS tests under zsh for polyglot verification
Related skills