This framework allows to write test files in pure Bash, without custom syntax, yet provide concise syntax and many features. My only concern is that it has only a few built-in assertions, but that can be solved by writing custom ones.
✔️ Test files are simple shell scripts, executed by the test framework. There's no need for any extra noise besides the test functions in a test file: no custom shebang line, no framework initialization code, and no custom imports.
test_example(){
assert_equals "hello" "world"
}
✔️ Test functions are simple bash functions without custom syntax. All functions which name is starting with test_
is considered a test function
✔️ bash_unit is parameterized with the list of test files to be executed. This means that it's trivial to focus on a single test file to execute. Moreover, it can also take a pattern to narrow test cases to be executed to the matching ones.
assert_equals
but lacks other essential ones, like assert_contains
.
✔️ All assertions provide a nice, easy to read report including the context and line number.
✔️ It’s possible to create new assertions by building functions on top of the existing assertions, although there's no dedicated lower-level API to support it. Custom assertions can be sourced from an external file.
✔️ If a test function name is starting with pending
or todo
it will be skipped which will be properly reflected in the report.
✔️ Supports all common techniques for mocking.
✔️ Additionally, it even has the
built-in fake
command
which is a shorthand for the function-export based mock technique,
making the tests even more clear and concise.
✔️ The project is around since 2016 and has regular releases. Overall much less popular than Bats or shUnit2, and has activity on the GitHub repository, but there's also much less forgotten issues and PRs.
✔️ Based on the getting started guide it was really easy to get started.