|
| 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_no_progress_suppresses_test_output_in_detailed_mode() { |
| 9 | + local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh |
| 10 | + local output |
| 11 | + |
| 12 | + output=$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --no-progress "$test_file" 2>&1) |
| 13 | + |
| 14 | + # Should NOT contain "Passed" (per-test progress output) |
| 15 | + assert_not_contains "Passed" "$output" |
| 16 | + # Should still show final summary |
| 17 | + assert_contains "Tests:" "$output" |
| 18 | + assert_contains "4 passed" "$output" |
| 19 | +} |
| 20 | + |
| 21 | +function test_no_progress_suppresses_test_output_in_simple_mode() { |
| 22 | + local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh |
| 23 | + local output |
| 24 | + |
| 25 | + output=$(./bashunit --no-parallel --simple --env "$TEST_ENV_FILE" --no-progress "$test_file" 2>&1) |
| 26 | + |
| 27 | + # Should NOT contain dots for passed tests |
| 28 | + assert_not_contains "...." "$output" |
| 29 | + # Should still show final summary |
| 30 | + assert_contains "Tests:" "$output" |
| 31 | + assert_contains "4 passed" "$output" |
| 32 | +} |
| 33 | + |
| 34 | +function test_no_progress_suppresses_file_headers() { |
| 35 | + local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh |
| 36 | + local output |
| 37 | + |
| 38 | + output=$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --no-progress "$test_file" 2>&1) |
| 39 | + |
| 40 | + # Should NOT contain "Running" file headers |
| 41 | + assert_not_contains "Running" "$output" |
| 42 | +} |
| 43 | + |
| 44 | +function test_no_progress_shows_correct_counts_in_summary() { |
| 45 | + local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh |
| 46 | + local output |
| 47 | + |
| 48 | + output=$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --no-progress "$test_file" 2>&1) |
| 49 | + |
| 50 | + # Summary should show passed count even though progress was suppressed |
| 51 | + assert_contains "4 passed" "$output" |
| 52 | + assert_contains "4 total" "$output" |
| 53 | +} |
| 54 | + |
| 55 | +function test_no_progress_still_shows_failures_in_summary() { |
| 56 | + local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh |
| 57 | + local output |
| 58 | + |
| 59 | + output=$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --no-progress "$test_file" 2>&1) || true |
| 60 | + |
| 61 | + # Should still show failure summary |
| 62 | + assert_contains "There was 1 failure" "$output" |
| 63 | + assert_contains "Tests:" "$output" |
| 64 | +} |
| 65 | + |
| 66 | +function test_no_progress_via_env_variable() { |
| 67 | + local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh |
| 68 | + local output |
| 69 | + |
| 70 | + output=$(BASHUNIT_NO_PROGRESS=true ./bashunit --no-parallel --skip-env-file "$test_file" 2>&1) |
| 71 | + |
| 72 | + assert_not_contains "Passed" "$output" |
| 73 | + assert_contains "4 passed" "$output" |
| 74 | +} |
0 commit comments