1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-09-29 12:38:26 +02:00

Add skipped count tests in the summary

This also update the behaviour of the summary, now it only display the
number of failures, and skipped tests also, if the numbers are greater
than zero.
This commit is contained in:
Henrique Moody 2013-10-30 22:10:00 -02:00 committed by Ross Duggan
parent 2c6fed1838
commit 3be82466a7
6 changed files with 64 additions and 3 deletions

View File

@ -11,6 +11,7 @@ if [[ "$header" =~ $header_pattern ]]; then
count="${header:3}"
index=0
failures=0
skipped=0
name=""
count_column_width=$(( ${#count} * 2 + 2 ))
else
@ -64,9 +65,15 @@ log() {
}
summary() {
printf "\n%d test%s, %d failure%s\n" \
"$count" "$(plural "$count")" \
"$failures" "$(plural "$failures")"
printf "\n%d test%s" "$count" "$(plural "$count")"
printf ", %d failure%s" "$failures" "$(plural "$failures")"
if [ "$skipped" -gt 0 ]; then
printf ", %d skipped" "$skipped"
fi
printf "\n"
}
printf_with_truncation() {
@ -139,6 +146,7 @@ while IFS= read -r line; do
"ok "* )
skip_expr="ok $index # skip (\(([^)]*)\))?"
if [[ "$line" =~ $skip_expr ]]; then
let skipped+=1
buffer skip "${BASH_REMATCH[2]}"
else
buffer pass

View File

@ -40,6 +40,30 @@ fixtures bats
[ ${lines[1]} = "ok 1 a passing test" ]
}
@test "summary passing tests" {
run filter_control_sequences bats -p $FIXTURE_ROOT/passing.bats
[ $status -eq 0 ]
[ "${lines[1]}" = "1 test, 0 failures" ]
}
@test "summary passing and skipping tests" {
run filter_control_sequences bats -p $FIXTURE_ROOT/passing_and_skipping.bats
[ $status -eq 0 ]
[ "${lines[2]}" = "2 tests, 0 failures, 1 skipped" ]
}
@test "summary passing and failing tests" {
run filter_control_sequences bats -p $FIXTURE_ROOT/failing_and_passing.bats
[ $status -eq 0 ]
[ "${lines[4]}" = "2 tests, 1 failure" ]
}
@test "summary passing, failing and skipping tests" {
run filter_control_sequences bats -p $FIXTURE_ROOT/passing_failing_and_skipping.bats
[ $status -eq 0 ]
[ "${lines[5]}" = "3 tests, 1 failure, 1 skipped" ]
}
@test "one failing test" {
run bats "$FIXTURE_ROOT/failing.bats"
[ $status -eq 1 ]

View File

@ -0,0 +1,7 @@
@test "a passing test" {
true
}
@test "a failing test" {
false
}

View File

@ -0,0 +1,7 @@
@test "a passing test" {
true
}
@test "a skipping test" {
skip
}

View File

@ -0,0 +1,11 @@
@test "a passing test" {
true
}
@test "a skipping test" {
skip
}
@test "a failing test" {
false
}

View File

@ -7,6 +7,10 @@ setup() {
export TMP="$BATS_TEST_DIRNAME/tmp"
}
filter_control_sequences() {
"$@" | sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g'
}
teardown() {
[ -d "$TMP" ] && rm -f "$TMP"/*
}