技能 编程开发 Bash脚本自动化测试模式

Bash脚本自动化测试模式

v20260509
bats-testing-patterns
本技能指南提供了使用Bats (Bash Automated Testing System) 为Shell脚本编写全面单元测试的模式和最佳实践。适用于需要进行脚本TDD、在CI/CD流程中设置自动化测试,以及验证Shell脚本行为、边缘案例和错误条件的场景。
获取技能
237 次下载
概览

Bats Testing Patterns

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.

Use this skill when

  • Writing unit tests for shell scripts
  • Implementing TDD for scripts
  • Setting up automated testing in CI/CD pipelines
  • Testing edge cases and error conditions
  • Validating behavior across shell environments

Do not use this skill when

  • The project does not use shell scripts
  • You need integration tests beyond shell behavior
  • The goal is only linting or formatting

Instructions

  • Confirm shell dialects and supported environments.
  • Set up a test structure with helpers and fixtures.
  • Write tests for exit codes, output, and side effects.
  • Add setup/teardown and run tests in CI.
  • If detailed examples are required, open resources/implementation-playbook.md.

Resources

  • resources/implementation-playbook.md for detailed patterns and examples.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
信息
分类 编程开发
名称 bats-testing-patterns
版本 v20260509
大小 4.77KB
更新时间 2026-05-10
语言