← ClaudeAtlas

test-shelllisted

BATS shell script testing. Use when writing or running shell script tests. Covers setup/teardown, assertions, mocking, helper patterns, and coverage with kcov.
lgtm-hq/ai-skills · ★ 0 · Testing & QA · score 66
Install: claude install-skill lgtm-hq/ai-skills
# Shell Testing with BATS BATS (Bash Automated Testing System) for testing shell scripts and libraries. ## Run Commands ```bash # Run all tests recursively bats --recursive tests/bats/ # Run specific test file bats tests/bats/unit/lib/test_log.bats # Run with TAP output (for CI) bats --tap tests/bats/ # Run with timing info bats --timing tests/bats/ # Filter tests by name pattern bats --filter "validate_semver" tests/bats/ # Run in parallel bats --jobs 4 tests/bats/ ``` ## Directory Structure ```text tests/ ├── bats/ │ ├── unit/ │ │ └── lib/ │ │ ├── test_log.bats │ │ ├── test_fs.bats │ │ ├── github/ │ │ │ └── test_output.bats │ │ └── release/ │ │ └── test_version.bats │ └── integration/ │ └── test_actions.bats ├── helpers/ │ ├── common.bash # Shared utilities │ ├── mocks.bash # Command mocking │ └── github_env.bash # GitHub Actions simulation └── fixtures/ └── json/ # Test data files ``` ## Test File Template ```bash #!/usr/bin/env bats # SPDX-License-Identifier: MIT # Purpose: Tests for scripts/ci/lib/example.sh load "../helpers/common" load "../helpers/mocks" setup() { setup_temp_dir export LIB_DIR } teardown() { teardown_temp_dir } # ============================================================================= # Function group description # ============================================================================= @test "function_name: does e