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
.batsfile contains multiple test cases defined using the@testannotation. -
Execution: Tests can be run individually or as a complete suite using the
batscommand.
This organization allows for modular and maintainable testing of our bash scripts and functions.
sudo apt-get install batsor
brew install batsbats testtest suite:
bats tests/*.batsor individual test:
bats tests/test_change_tracking_branch.batsWe'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