view README.md @ 3:0798045f37b5 default tip

Add blog post link to README.
author Jang Rush <weakish@gmail.com>
date Mon, 05 Sep 2022 10:50:14 +0000
parents bce8021ad094
children
line wrap: on
line source

# Bricolage

Bricolage is an ultimately minimal testing library for UNIX Shell. It follows the idea of klud.js and gambiarra.lua

## Usage

	# include b.sh
	. b.sh

	# optionally define pass/fail handlers
	pass() {
		echo "PASS $*"
	}

	fail() {
		echo "FAIL $*"
	}

	# write your test functions
	mytest() {
		# inside use test assertions
		ok 1 -eq 1
		ok $FOO = "somevalue"
 		# mock/spy some commands
		spy ls
		# give fake command output
		echo "file.txt" > $T/spy.ls
		# use fake ls
		ls /some/dir
		# ensure that argument was passed correctly
		ok $(cat $T/spy.ls.args) = "/some/dir"
		# ensure that command return expected output
		ok $(cat $T/spy.ls.stdout) = "file.txt"
	}

	# run your tests
	bricolage mytest

	# cleanup
	rm -r $T

## License

Distributed under MIT license

## Reference

- [Ultimately minimal unit testing][blog], an introduction of Bricolage's philosophy,
  written by its author.
- [bitbucket.org/zserge/bricolage][bb], the original code repository,
  404 after BitBucket sunsetting Mercurial hosting.

[blog]: https://zserge.com/posts/minimal-testing/
[bb]: http://bitbucket.org/zserge/bricolage

## License

Distributed under MIT license