Skip to content

Instantly share code, notes, and snippets.

@Potherca
Last active April 22, 2020 05:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Potherca/0df1169470c235be7bb921943b15f637 to your computer and use it in GitHub Desktop.
Save Potherca/0df1169470c235be7bb921943b15f637 to your computer and use it in GitHub Desktop.
BATS Assertion Libraries comparison

"Who would dare assert that we know all there is to be known?" ~ Galileo Galilei

Introduction

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.

Legend

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

Assert comparison Table

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 using assert_output --partial or assert_output --regex options
  • 3 ZBA supports assert_starts_with by using assert_contains with a /^.../ regex. (same with refute_starts_with)
  • 4 ZBA supports asserting an explicit status "N" using assert_failure N

Summary

22 Function present across all projects

@Potherca
Copy link
Author

Cool! Added. I've also added fail for ZBA (through bats-support).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment