bats-testing-patterns
Installation
SKILL.md
Bats Testing Patterns
Bats (bats-core) runs .bats files as TAP-compliant Bash tests. Each @test block runs in its own subshell/process; state never leaks between tests. export a variable when a command run via run within the same test needs to see it.
Test File Anatomy
#!/usr/bin/env bats
setup() { # before EACH test
export SCRIPT="${BATS_TEST_DIRNAME}/../bin/script.sh"
}
setup_file() { # once, before the file's first test
export FIXTURE_DB="$BATS_FILE_TMPDIR/seed.db"
}