Skip to content

Instantly share code, notes, and snippets.

@MichaelDimmitt
Last active April 21, 2019 12:45
Show Gist options
  • Save MichaelDimmitt/94b843b17e7c1a3b2da1adc7fb48f855 to your computer and use it in GitHub Desktop.
Save MichaelDimmitt/94b843b17e7c1a3b2da1adc7fb48f855 to your computer and use it in GitHub Desktop.
cd ~ &&
startingFolderLocation=$OLDPWD &&
git clone https://github.com/bats-core/bats-core.git &&
cd bats-core &&
sudo ./install.sh /usr/local &&
cd $startingFolderLocation &&
mkdir bats_test_suite_example &&
cd bats_test_suite_example &&
echo '
#!/usr/bin/env bats
@test "addition using bc" {
result="$(echo 2+2 | bc)"
[ "$result" -eq 4 ]
}
@test "addition using dc" {
result="$(echo 2 2+p | dc)"
[ "$result" -eq 4 ]
}
' >> addition.bats &&
bats addition.bats
## If everything worked you just ran two tests with the bats test suite
## For more information read the official Readme: https://github.com/sstephenson/bats
## The above example comes from the official Readme with a few additions from myself to make it a oneliner.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment