A Bash testing framework using TAP protocol.
bashTest depends on my aother project bashLib which is a collection of commonly used Bash functions. Just clone bashLib to one of the following locations, bashTest will try to fiind them in the following order.
1. PROJECT_ROOT/bundles/bashLib/src/bashLib"
2. PROJECT_ROOT/../bashLib/src/bashLib"
3. /usr/share/lib/bashLib/bashLib"
The symtax is pretty much like many other *unit testing frameworks.
-
_set_upCalled at the beginning every time a test runs to set up necessary test facility.
-
_tear_downCalled at the end every time a test runs to clean up the test facility for next run.
-
_test_run $msg $testRuns a actual test. First argument is the msg that will be print to the stdout for test harness to process. The second is the actual test content to run, quotes must be carefully handled.
-
_test_doneCalled after all tests finished, the main purpose is to print the test plan.
-
_test_expect_exists "$path"Fail if
$pathmissing -
_test_expect_missing "$path"Fail if
$pathexists -
_test_expect_symlink "$target" "$source"Fail if
$targetis not symlinked to$source -
_test_expect_directory "$path"Fail if
$pathis not a directory -
_test_expect_expr_true "$expr"Fail if the result of evaluating
$expris false -
_test_expect_expr_false "$expr"Fail if the result of evaluating
$expris true -
_test_expect_expr_match "$expr1" "$expr2"Fail if
$expr1does not match$expr2 -
_test_expect_expr_unmatch "$expr1" "$expr2"Fail if
$expr1does match$expr2
-
TEST_COUNTCounter of tests that have been executed.
-
TEST_FIELDA directory where each test will be run, and is unique for each test.
For an example using this framework, take a look at a script called dotploy I wrote to manage and deploy the dot files.
