Use the root Makefile
to build and run tests in a container preloaded with
with bats and other dependencies.
cd /path/to/project
make tests
Limit which tests to run by exporting or passing TEST
, e.g.
make tests TEST=00-makefile.bats
Some tests make remote network calls. This can slow things down, esp.
on a system with an unresponsive resolver. Skip these by exporting or passing SKIP_NETWORK_TEST
, e.g.
SKIP_NETWORK_TEST=true make tests
Already have bats installed? Manually trigger tests from the tests/bats directory -- clearing the temp directory beforehand.
rm -rf tests/bats/tmp && bats tests/bats/
For now, use existing bats/ files as reference. Group tests in a well named file and numerically prefix to maintain execution order.
Fixtures are useful for mocking larger output and structures, and stored under the tests/fixtures directory.
Functions for working with fixtures are provided by helpers.bash (fixture/cat
and fixture/cp
).
compare the application's output to a fixture named 'sources.list'.
diff $TMPDIR/output <(fixture/cat sources.list)
copy the 'sources.list' fixture to TMPDIR/sources.list
fixture/cp sources.list $TMPDIR/sources.list