1
0
mirror of https://github.com/sstephenson/bats.git synced 2026-02-25 09:18:10 +01:00

Test (and fix) that teardown runs once after each test

This commit is contained in:
Sam Stephenson
2011-12-28 21:20:43 -06:00
parent 6e65ef449b
commit 43d1972b0e
4 changed files with 39 additions and 5 deletions

View File

@@ -1,15 +1,17 @@
LOG="$TMP/setup.log"
setup() {
echo "$BATS_TEST_NAME" >> "$TMP/setup.log"
echo "$BATS_TEST_NAME" >> "$LOG"
}
@test "one" {
true
[ "$(tail -n 1 "$LOG")" = "test_one" ]
}
@test "two" {
true
[ "$(tail -n 1 "$LOG")" = "test_two" ]
}
@test "three" {
true
[ "$(tail -n 1 "$LOG")" = "test_three" ]
}

17
test/fixtures/teardown.bats vendored Normal file
View File

@@ -0,0 +1,17 @@
LOG="$TMP/teardown.log"
teardown() {
echo "$BATS_TEST_NAME" >> "$LOG"
}
@test "one" {
true
}
@test "two" {
false
}
@test "three" {
true
}