root@VM-8-10-ubuntu:/opt/test/bach/tests# cat ./test-assert-fail.test.sh
#!/usr/bin/env bashset -euo pipefail
curr_dir="$(cd"$(dirname "$BASH_SOURCE")";pwd -P)"source"${curr_dir}"/../bach.sh
test-ASSERT-FAIL-exit-1-should-success(){ @echo This testcase SHOULD SUCCESS!
@echo Because the exit code is non-zero.
do-something
exit1}
运行结果
1
2
3
4
5
root@VM-8-10-ubuntu:/opt/test/bach/tests# ./test-assert-fail.test.sh
1..1
ok 1 - ASSERT FAIL exit1 should success
# -----# All tests: 1, failed: 0, skipped: 0