simplest unit testing framework for bash
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests
.codeclimate.yml
.travis.yml
CONTRIBUTING.md
LICENSE
Makefile
README.md
minibashtest.sh

README.md

minibashtest

Build Status Packagecloud Code Climate MIT license

Overview

This is the most simple unit testing framework I could come up with. The intention here is to serve as an example of how easy it can be to get started with unit testing, even for something like bash that traditionally has less of a unit testing culture. It's heavily inspired by minunit.

Usage

#!/usr/bin/env bash

source 'minibashtest.sh'

function test_one_is_one {
  assert "[ 1 -eq 1 ]" "failed to assert that 1 equals 1"
}

function test_one_is_not_two {
  assert "[ 1 -neq 2 ]" "failed to assert that 1 is not 2"
}

run_test_suite

Setup/TearDown

If you define functions called setup or tear_down, they will be called before and after each test function respectively.

Advanced Testing

Fortunately a lot of people have given unit testing in bash some thoughts in the past. So if you want something more than just basic assertions, check thosse out: