bats-testing-patterns
Build Reliable Bats Tests for Shell Scripts
Shell scripts often lack repeatable tests for output, exit codes, files, and failures. This skill provides practical Bats patterns for maintainable local and CI test suites.
Install with my Agent
Copy this request to your Agent. It includes the canonical Skill page and manifest.
Review the Skillstore skill "bats-testing-patterns" from https://skillstore.io/skills/sickn33-bats-testing-patterns.md and its manifest at https://skillstore.io/api/skills/sickn33-bats-testing-patterns/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.Your Agent should still show its plan and request any confirmation required by the security policy.
Agent-readable resources
Use these links when an AI agent, crawler, or script needs clean context instead of reading the full page.
Test it
Using "bats-testing-patterns". Create tests for a backup script that requires a destination directory.
Expected outcome:
- A success test verifies the archive path, status, and reported filename.
- Failure tests cover a missing destination, an unwritable directory, and an unavailable source.
- Setup creates isolated fixtures, while teardown removes only the generated test directory.
Using "bats-testing-patterns". Test a shell function that calls curl and parses a response.
Expected outcome:
- A command stub returns controlled success, timeout, and malformed response cases.
- Assertions verify exit codes and user-facing errors without making network requests.
- Each test resets the stub environment to prevent state leakage.
Using "bats-testing-patterns". Prepare existing Bats tests for continuous integration.
Expected outcome:
The result organizes fixtures, removes shared mutable state, adds dependency checks, and defines repeatable test commands for the CI workflow.
Security Audit
SafeAll 33 static findings are false positives caused by markdown examples, fixed test commands, project-relative paths, and ordinary shell redirection. No prompt injection, malicious intent, credential access, covert network activity, or unsafe executable payload was found.
Risk Factors
โ๏ธ External commands (17)
๐ Network access (1)
๐ Filesystem access (13)
Share & cite this report
Share the versioned assessment report, neutral badge, embed card, and citations. Skillstore reports evidence without deciding whether this Skill is safe.
Copy report link
https://skillstore.io/skills/sickn33-bats-testing-patterns/audits/5?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown badge
[](https://skillstore.io/skills/sickn33-bats-testing-patterns?utm_source=security_passport_badge)HTML badge
<a href="https://skillstore.io/skills/sickn33-bats-testing-patterns?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/sickn33-bats-testing-patterns/security.svg" alt="Skillstore security assessment" loading="lazy"></a>Embed card
<iframe src="https://skillstore.io/embed/skills/sickn33-bats-testing-patterns.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>Academic citations (APA ยท BibTeX ยท CFF)
APA citation
sickn33. (2026). bats-testing-patterns security audit report (audit version 5) [Author version unspecified]. Skillstore. https://skillstore.io/skills/sickn33-bats-testing-patterns/audits/5BibTeX citation
@techreport{sickn33-sickn33-bats-testing-patterns-2026,
author = {sickn33},
title = {bats-testing-patterns security audit report (audit version 5)},
institution = {Skillstore},
year = {2026},
number = {5},
url = {https://skillstore.io/skills/sickn33-bats-testing-patterns/audits/5},
note = {Author version unspecified}
}CITATION.cff
cff-version: 1.2.0
message: "If you use this Skill, cite its author and this versioned security audit report."
title: "bats-testing-patterns security audit report (audit version 5)"
version: "unspecified"
type: report
authors:
- name: "sickn33"
date-released: "2026-08-14"
url: "https://skillstore.io/skills/sickn33-bats-testing-patterns/audits/5"
identifiers:
- type: other
value: "skillstore:sickn33-bats-testing-patterns:audit:5"
description: "Skillstore immutable audit report identifier"
Compare variants
2 installable variantsEach author remains a separate installable skill. The recommended variant is ranked by Skillstore evidence.
Why this variant is first
sickn33-bats-testing-patterns
2026-08-21
wshobson-bats-testing-patterns
2026-08-21
Skillstore Score
Why this score Evidence Confidence: HighWhat You Can Build
Test a shell utility
Create focused Bats tests for normal output, invalid arguments, exit codes, and file side effects.
Add regression coverage
Convert reported shell failures into isolated fixtures and repeatable tests before changing production scripts.
Standardize CI checks
Organize a portable Bats suite and run it consistently across supported shell environments.
Try These Prompts
Write Bats tests for [script] covering successful output, one invalid argument, and expected exit codes.
Design Bats setup, teardown, and fixtures for [script]. Verify created files, contents, permissions, and cleanup.
Create Bats tests for [function] that stub [dependency]. Cover dependency success, failure, malformed output, and missing installation.
Review [test suite] for Bash, sh, and dash portability. Improve fixtures, parallel safety, failure coverage, and CI execution.
Best Practices
- Test one behavior per case and name the expected outcome clearly.
- Create isolated fixtures with secure temporary directories and reliable teardown.
- Cover success, failure, edge cases, and supported shell environments in CI.
Avoid
- Do not depend on live services when a controlled command stub can isolate behavior.
- Do not share writable fixture state between tests or parallel workers.
- Do not assert only output while ignoring exit codes and filesystem side effects.
Frequently Asked Questions
What is Bats?
Which shells can these patterns test?
Does this skill install Bats?
Can it test external commands without network access?
Can Bats tests run in CI?
Does it provide code coverage metrics?
Developer Details
Author
sickn33License
MIT
Skillstore revision
r2
Version notice
The author did not declare a version.
Repository
https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/bats-testing-patternsRef
5a26d1d61d694db29af9b138c661c1981076d9df
Maintenance freshness
8/15/2026
Usage
7 downloads ยท 93 views
File structure