Our tests are organized using the Bats (Bash Automated Testing System) framework. Here's a brief overview:
-
Location: All test files are located in the
tests/
directory. -
Naming Convention: Test files follow the naming pattern
test_*.bats
. -
Helper File: Common helper functions are defined in
tests/test_helper.bash
. -
Structure: Each
.bats
file contains multiple test cases defined using the@test
annotation. -
Execution: Tests can be run individually or as a complete suite using the
bats
command.
This organization allows for modular and maintainable testing of our bash scripts and functions.
sudo apt-get install bats
or
brew install bats
bats test
test suite:
bats tests/*.bats
or individual test:
bats tests/test_change_tracking_branch.bats
We've added a GitHub Action to automatically run our tests on every push and pull request. Here's how it works:
- The action is defined in
.github/workflows/run-tests.yml
- It runs on Ubuntu latest
- It installs bats and runs all tests in the
tests/
directory