Skip to content

Add BATS tests for all shell scripts (9 scripts) #456

Description

@sfloess

Summary

Per FlossWare org standard, all shell scripts must have BATS (Bash Automated Testing System) tests — even a single script or function gets a test.

What to do

  1. Add BATS as a dev dependency
  2. Create a tests/bats/ directory (or tests/ if no other test framework)
  3. Write .bats test files for every .sh script and shell function
  4. Add BATS to CI (GitHub Actions)

Shell scripts in this repo

9 shell scripts found.

BATS setup

# Install
git clone https://github.com/bats-core/bats-core.git
cd bats-core && sudo ./install.sh /usr/local

# Helper libraries (recommended)
git clone https://github.com/bats-core/bats-support.git test/test_helper/bats-support
git clone https://github.com/bats-core/bats-assert.git test/test_helper/bats-assert

Example test

#!/usr/bin/env bats

@test "script runs without error" {
  run ./my-script.sh --help
  [ "$status" -eq 0 ]
}

@test "output contains expected string" {
  run ./my-script.sh
  [[ "$output" == *"expected"* ]]
}

Rule

FlossWare org standard: every shell script gets BATS tests, no exceptions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions