1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-11-17 03:32:27 +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 #!/usr/bin/env bats
FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures" FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures"
TMP="$BATS_TEST_DIRNAME/tmp"
teardown() {
rm -f "$TMP"/*
}
@test "no arguments prints usage instructions" { @test "no arguments prints usage instructions" {
run bats run bats
@ -46,3 +51,10 @@ FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures"
run bats "$FIXTURE_ROOT/environment.bats" run bats "$FIXTURE_ROOT/environment.bats"
[ $status -eq 0 ] [ $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 @@
*