Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Writes unit tests for shell scripts with Bats, covering fixtures, error conditions, and CI/CD integration.
Use this skill ↓55% 77%+23 ptsof test cases passed
Passed 17 of 22 test cases with the skill, and 12 of 22 without it.
3 of 3 safety checks passed
17 agent runs
Comprehensive guidance for writing comprehensive unit tests for shell scripts using Bats (Bash Automated Testing System), including test patterns, fixtures, and best practices for production-grade shell testing.
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
#!/usr/bin/env bats
@test "Function fails with missing file" {
run my_function "/nonexistent/file.txt"
[ "$status" -ne 0 ]
[[ "$output" == *"not found"* ]]
}
@test "Function fails with invalid input" {
run my_function ""
[ "$status" -ne 0 ]
}
@test "Function fails with permission denied" {
touch "$TMPDIR/readonly.txt"
chmod 000 "$TMPDIR/readonly.txt"
run my_function "$TMPDIR/readonly.txt"
[ "$status" -ne 0 ]
Published skills whose descriptions closely match this one, with their benchmark result.
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.