Skip to content

Commit a03a938

Browse files
committed
test(acceptance): add TAP output format snapshot tests
1 parent b844f1f commit a03a938

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
function set_up_before_script() {
5+
TEST_ENV_FILE="tests/acceptance/fixtures/.env.default"
6+
}
7+
8+
function test_tap_output_passing_tests_matches_snapshot() {
9+
local test_file=tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh
10+
11+
assert_match_snapshot "$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --output tap "$test_file")"
12+
}
13+
14+
function test_tap_output_failing_tests_matches_snapshot() {
15+
local test_file=tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh
16+
17+
assert_match_snapshot "$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --output tap "$test_file" 2>&1 || true)"
18+
}
19+
20+
function test_tap_output_env_var_equivalent_to_flag() {
21+
local test_file=tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh
22+
local via_flag
23+
local via_env
24+
25+
via_flag=$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --output tap "$test_file")
26+
via_env=$(BASHUNIT_OUTPUT_FORMAT=tap ./bashunit --no-parallel --env "$TEST_ENV_FILE" "$test_file")
27+
28+
assert_equals "$via_flag" "$via_env"
29+
}
30+
31+
function test_tap_output_exits_non_zero_on_failure() {
32+
local test_file=tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh
33+
34+
./bashunit --no-parallel --env "$TEST_ENV_FILE" --output tap "$test_file" >/dev/null 2>&1
35+
assert_general_error "$?"
36+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
TAP version 13
2+
# tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh
3+
ok 1 - Assert same
4+
ok 2 - Assert contains
5+
not ok 3 - Assert failing
6+
---
7+
Expected '1'
8+
but got '0'
9+
...
10+
ok 4 - Assert greater and less than
11+
ok 5 - Assert empty
12+
13+
1..5
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
TAP version 13
2+
# tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh
3+
ok 1 - Assert same
4+
ok 2 - Assert contains
5+
ok 3 - Assert greater and less than
6+
ok 4 - Assert empty
7+
8+
1..4

0 commit comments

Comments
 (0)