1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-12-26 06:29:47 +01:00

Test that setup runs once before each test

This commit is contained in:
Sam Stephenson 2011-12-28 20:46:24 -06:00
parent 098d993eb4
commit aecc6b55dc
3 changed files with 31 additions and 0 deletions

View File

@ -1,6 +1,11 @@
#!/usr/bin/env bats
FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures"
TMP="$BATS_TEST_DIRNAME/tmp"
teardown() {
rm -f "$TMP"/*
}
@test "no arguments prints usage instructions" {
run bats
@ -46,3 +51,10 @@ FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures"
run bats "$FIXTURE_ROOT/environment.bats"
[ $status -eq 0 ]
}
@test "setup is run once before each test" {
rm -f "$TMP/setup.log"
run bats "$FIXTURE_ROOT/setup.bats"
run cat "$TMP/setup.log"
[ ${#lines[@]} -eq 3 ]
}

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

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

2
test/tmp/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*