Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

BATS bash tests

The tests in this folder are not regular Pytest tests. They are implemented with BATS to test scripts in the bin folder of this repo.

Prerequisites

Install BATS: If you don't have BATS installed, you need to install it first. On a Unix-like system, you can usually install it using a package manager.

For Debian-based systems (e.g., Ubuntu):

sudo apt-get update
sudo apt-get install bats

For macOS using Homebrew:

brew install bats-core

Alternatively, you can install BATS manually by cloning the repository and adding the bin folder to your PATH environment variable.

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

Writing tests

Create a file with a .bats extension, for example, test_example.bats. Here’s a simple test file:

#!/usr/bin/env bats
@test "test description" {
  run echo "hello"
  [ "$status" -eq 0 ]
  [ "$output" = "hello" ]
}

Running Tests

To run the tests, simply execute the bats command followed by the test file or directory containing test files:

bats test_example.bats

You can also run all .bats files in a directory:

bats tests/bin

To run with some debug information, you can use this:

bats --trace --verbose-run --print-output-on-failure -r tests/bin/