mirror of
https://github.com/sstephenson/bats.git
synced 2024-12-25 14:09:43 +01:00
Test that setup runs once before each test
This commit is contained in:
parent
098d993eb4
commit
aecc6b55dc
|
@ -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
17
test/fixtures/setup.bats
vendored
Normal 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
2
test/tmp/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
|
Loading…
Reference in New Issue
Block a user