1
0
mirror of https://github.com/sstephenson/bats.git synced 2026-02-26 01:38:11 +01:00

Suite support for aggregating multiple tests under a single run

This commit is contained in:
Sam Stephenson
2012-11-16 14:25:45 -06:00
parent f8f78b5cd3
commit 19a05cc77d
18 changed files with 120 additions and 7 deletions

View File

@@ -1,11 +1,7 @@
#!/usr/bin/env bats
FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures"
export TMP="$BATS_TEST_DIRNAME/tmp"
teardown() {
rm -f "$TMP"/*
}
load test_helper
fixtures bats
@test "no arguments prints usage instructions" {
run bats

3
test/fixtures/suite/multiple/a.bats vendored Normal file
View File

@@ -0,0 +1,3 @@
@test "truth" {
true
}

7
test/fixtures/suite/multiple/b.bats vendored Normal file
View File

@@ -0,0 +1,7 @@
@test "more truth" {
true
}
@test "quasi-truth" {
[ -z "$FLUNK" ]
}

3
test/fixtures/suite/single/test.bats vendored Normal file
View File

@@ -0,0 +1,3 @@
@test "a passing test" {
true
}

43
test/suite.bats Normal file
View File

@@ -0,0 +1,43 @@
#!/usr/bin/env bats
load test_helper
fixtures suite
@test "running a suite with no test files" {
run bats "$FIXTURE_ROOT/empty"
[ $status -eq 0 ]
[ $output = "1..0" ]
}
@test "running a suite with one test file" {
run bats "$FIXTURE_ROOT/single"
[ $status -eq 0 ]
[ ${lines[0]} = "1..1" ]
[ ${lines[1]} = "ok 1 a passing test" ]
}
@test "counting tests in a suite" {
run bats -c "$FIXTURE_ROOT/single"
[ $status -eq 0 ]
[ $output -eq 1 ]
run bats -c "$FIXTURE_ROOT/multiple"
[ $status -eq 0 ]
[ $output -eq 3 ]
}
@test "aggregated output of multiple tests in a suite" {
run bats "$FIXTURE_ROOT/multiple"
[ $status -eq 0 ]
[ ${lines[0]} = "1..3" ]
echo "$output" | grep "^ok . truth"
echo "$output" | grep "^ok . more truth"
echo "$output" | grep "^ok . quasi-truth"
}
@test "a failing test in a suite results in an error exit code" {
FLUNK=1 run bats "$FIXTURE_ROOT/multiple"
[ $status -eq 1 ]
[ ${lines[0]} = "1..3" ]
echo "$output" | grep "^not ok . quasi-truth"
}

11
test/test_helper.bash Normal file
View File

@@ -0,0 +1,11 @@
fixtures() {
FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures/$1"
}
setup() {
export TMP="$BATS_TEST_DIRNAME/tmp"
}
teardown() {
rm -f "$TMP"/*
}