"Who would dare assert that we know all there is to be known?" ~ Galileo Galilei
At the time of this writing there are 3 separate libraries that offer assertions for the Bash Automated Testing System (otherwise known as BATS).
These are:
This page shows a comparison of the functions each projects offers.
Symbol | Meaning |
---|---|
JBA | jasonkarns/bats-assert |
TBA | thingsym/bats-assertion |
ZBA | ztombol/bats-assert |
foo |
Affirmatory function |
foo |
Negatory function |
π | Function present |
βοΈ | Other function can be used |
βοΈ | Alias present |
Function Name | Also Known As | JBA | TBA | ZBA |
---|---|---|---|---|
fail |
flunk |
βοΈ | βοΈ 1 | |
assert |
π | π | ||
refute |
π | π | ||
assert_contains |
assert_output_contains |
π | βοΈ 2 | |
refute_contains |
refute_output_contains |
π | βοΈ 2 | |
assert_equal |
π | π | π | |
refute_equal |
assert_fail_equal |
βοΈ | ||
assert_line |
π | π | ||
refute_line |
π | π | ||
assert_lines_equal |
π | |||
refute_lines_equal |
assert_fail_lines_equal |
βοΈ | ||
assert_lines_match |
π | |||
refute_lines_match |
assert_fail_lines_match |
βοΈ | ||
assert_match |
π | |||
refute_match |
assert_fail_match |
βοΈ | ||
assert_output |
π | π | ||
refute_output |
π | |||
assert_success |
π | π | π | |
refute_success |
assert_failure |
βοΈ | βοΈ | βοΈ |
assert_starts_with |
π | βοΈ 3 | ||
refute_starts_with |
βοΈ 3 | |||
assert_status |
π | βοΈ 4 | ||
TOTAL (Per project) | 12 | 11 | 15 |
- 1 ZBA supports
fail
through its dependency on bats-support - 2 ZBA supports
assert_contains
by usingassert_output --partial
orassert_output --regex options
- 3 ZBA supports
assert_starts_with
by usingassert_contains
with a/^.../
regex. (same withrefute_starts_with
) - 4 ZBA supports asserting an explicit status "N" using
assert_failure N
22 Function present across all projects
assert_contains
by usingassert_output
with the--partial
or--regex
optionsassert_success
are not equivalent because JBA'sassert_success
checks both status and output. ZBA's only checks status. (uncertain about TBA)assert_contains
andassert_output_contains
(from JBA) should be considered aliases. only difference is stdin handling which ought to be unifiedassert_starts_with
by usingassert_contains
with a/^.../
regex. (same withrefute_starts_with
)assert_status
is the same as combining JBA's and ZBA'sassert_success
andassert_failure
(assert_success
is the same asassert_status 0
)pass
helper would do, since a test passes by default. how would you expect that to be used?refute_status
would primarily be used to assert that the exit code is != 0, whichassert_failure
does, so I'd consider that nearly covered.