Last active
April 19, 2018 01:49
Exploration of https://github.com/bats-core/.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This function will be called before each test case. | |
setup () { | |
# This block will run only for the first test in this file. | |
# Usefull for setting up resources that should last for all tests. | |
if [[ "$BATS_TEST_NUMBER" -eq 1 ]]; then | |
: | |
fi | |
: | |
} | |
# This function will be called after each test case. | |
teardown () { | |
# This block will run only for the last test case in this file. | |
# Usefull for tearing down global resources. | |
if [[ "${#BATS_TEST_NAMES[@]}" -eq "$BATS_TEST_NUMBER" ]]; then | |
: | |
fi | |
: | |
} | |
@test "hello, world" { | |
run echo "Hello, bats!" | |
[ "$status" -eq 0 ] | |
[ "$output" = "Hello, bats!" ] | |
} | |
@test "can handle failing commands" { | |
run rm inexistent_file # should return 1 | |
[ "$status" -eq 1 ] | |
run grep "." inexistent_file # should return 2 | |
[ "$status" -eq 2 ] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run with
Expected output: