Use case

You wrote an application. Following sane development practices, you want to
protect yourself against introducing errors with a test suite. Even though most
languages have excellent testing tools, modifying process state (input stdin,
command line arguments argv, environment variables) is awkard in most
languages. The shell was made to do just that, so why don't run the tests in
your shell?

Reference

assert <command> [stdout] [stdin]

Check for an expected output when running your command. stdout supports all
control sequences printf(1) interprets, eg. \n for a newline. The default
stdout is assumed to be empty.

assert_raises <command> [exitcode] [stdin]

Verify command terminated with the expected status code. The default
exitcode is assumed to be 0.

assert_end [suite]

Finalize a test suite and print statistics.

Command line options

See assert.sh --help for command line options on test runners.

-v, --verbose

Generate real-time output for every individual test run.

-x, --stop

Stop running tests after the first failure.
(Default: run all tests.)

-i, --invariant

Do not measure runtime for suites. Useful mainly to parse
test output.

-d, --discover

Collect test suites and number of tests only; don't run any
tests.

-h

Show brief usage information and exit.

--help

Show usage manual and exit.

Environment variables

variable

corresponding option

$DEBUG

--verbose

$STOP

--stop

$INVARIANT

--invariant

$DISCOVERONLY

--discover-only

Changelog

Related projects

ShUnit is a testing framework of the xUnit family for Bourne derived shells.
It is quite feature-rich but requires a whole lot of boilerplate to write a
basic test suite. assert.sh aims to be lightweight and easy to setup.

shUnit2 is a modern xUnit-style testing framework. It comes with a bunch of
magic to remove unneccessary verbosity. It requires extra care when crafting
test cases with many subprocess invocations as you have to fall back to shell
features to fetch results. assert.sh wraps this functionality out of the
box.

A Test Anything Protocol (TAP) producer with an inherently natural-language-
style API. Unfortunately it's only of draft quality and decouples the test
runner from analysis, which does not allow for assert.sh features such as
--collect-only and --skip.