Release 0.44.0
Release 0.44.0 helps you test and document your own checks, called custom assertions. It also gives you more control over saved expected output and catches setup mistakes that could previously produce misleading results.
Build and test your own checks
bashunit::assert_that runs a command and records whether the check passed in one call. bashunit::assert_once lets a check made of several smaller checks count and report once under its own label. Existing totals stay unchanged unless you choose to use it (#915, #917).
The new assert_assertion_passes, assert_assertion_fails, and assert_assertion_fails_with helpers test what your check reports. They keep its counts and output separate, so an expected failure does not fail the surrounding test (#916).
function test_positive_assertion() {
assert_assertion_passes assert_positive_number 3
assert_assertion_fails_with "positive number" assert_positive_number 0
}Here, assert_positive_number is your project's check. Load the setup file that defines it to list its documentation alongside the built-in reference. Use --custom to list only your project's checks (#918).
bashunit doc --custom --boot tests/bootstrap.shReview saved expected output
A snapshot is saved expected output that later runs compare against. Use --snapshot-update to replace existing snapshots after an intentional change, optionally narrowing the run with --filter. Snapshots containing markers for text you chose to ignore are left alone. In automated checks, --no-snapshot-create makes a missing snapshot fail instead of silently saving the first reference. --snapshot-report-unused lists leftovers from renamed or deleted tests without deleting anything. It requires a full run (#900, #901, #902).
bashunit tests/ --no-snapshot-create
bashunit tests/ --snapshot-report-unusedCatch mistakes before trusting a pass
A spy tracks calls to a command. Checks of those calls now reject a command that was never registered for tracking, instead of reporting zero calls. Comparing arguments one at a time distinguishes one argument containing a space from two separate arguments. Failed checks show the recorded calls.
Invalid options, numeric settings, and missing setup or environment files now produce errors. Coverage, which reports how much code the tests reach, also gains an xtrace method of recording execution on Bash 4.1 and later. Automatic selection keeps the existing trap method on older shells. Bash 3.0 remains the minimum supported version.
See the full changelog for 0.44.0 on GitHub.