Skip to content

Commit

Permalink
test: adapt snapshots tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Chemaclass committed Oct 13, 2024
1 parent a03100d commit 5a370f7
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 26 deletions.
14 changes: 10 additions & 4 deletions src/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,18 @@ function runner::call_test_functions() {
}

function runner::render_running_file_header() {
if ! env::is_simple_output_enabled && ! parallel::is_enabled; then
printf "${_COLOR_BOLD}%s${_COLOR_DEFAULT}\n" "Running: $script"
if parallel::is_enabled; then
return
fi

if env::is_simple_output_enabled && env::is_verbose_enabled; then
printf "\n${_COLOR_BOLD}%s${_COLOR_DEFAULT}" "Running: $script"
if ! env::is_simple_output_enabled; then
if env::is_verbose_enabled; then
printf "\n${_COLOR_BOLD}%s${_COLOR_DEFAULT}\n" "Running $script"
else
printf "${_COLOR_BOLD}%s${_COLOR_DEFAULT}\n" "Running $script"
fi
elif env::is_verbose_enabled; then
printf "\n\n${_COLOR_BOLD}%s${_COLOR_DEFAULT}" "Running $script"
fi
}

Expand Down
8 changes: 5 additions & 3 deletions tests/acceptance/bashunit_execution_error_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function test_bashunit_when_a_execution_error() {
}

fixture_start=$(
printf "Running ./tests/acceptance/fixtures/test_bashunit_when_a_execution_error.sh"
printf "${color_bold}%s${color_default}\n" "Running ./tests/acceptance/fixtures/test_bashunit_when_a_execution_error.sh"
format_fail_title "✗ Failed" ": Error"
format_expect_title "Expected"
format_expect_value "'127'"
Expand All @@ -53,7 +53,9 @@ function test_bashunit_when_a_execution_error() {
todo "Add snapshots with regex to assert this test (part of the error message is localized)"
todo "Add snapshots with simple/verbose modes as in bashunit_pass_test and bashunit_fail_test"

assert_contains "$fixture_start" "$(./bashunit --no-parallel --env "$TEST_ENV_FILE" "$test_file")"
assert_contains "$fixture_end" "$(./bashunit --no-parallel --env "$TEST_ENV_FILE" "$test_file")"
# shellcheck disable=SC2155
local actual="$(./bashunit --no-parallel --env "$TEST_ENV_FILE" "$test_file")"
assert_contains "$fixture_start" "$actual"
assert_contains "$fixture_end" "$actual"
assert_general_error "$(./bashunit --no-parallel --env "$TEST_ENV_FILE" "$test_file")"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Running ./tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh
Running ./tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh
✓ Passed: Assert same
✓ Passed: Assert contains
✗ Failed: Assert failing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Running ./tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh
Running ./tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh
✓ Passed: Assert same
✓ Passed: Assert contains
✗ Failed: Assert failing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Running ./tests/acceptance/fixtures/tests_path/a_test.sh
Running ./tests/acceptance/fixtures/tests_path/a_test.sh
✓ Passed: Assert greater and less than
✓ Passed: Assert empty
Running ./tests/acceptance/fixtures/tests_path/other_test.sh
Running ./tests/acceptance/fixtures/tests_path/other_test.sh
✓ Passed: Assert same
✓ Passed: Assert contains

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Running ./tests/acceptance/fixtures/tests_path/a_test.sh
Running ./tests/acceptance/fixtures/tests_path/a_test.sh
✓ Passed: Assert greater and less than
✓ Passed: Assert empty
Running ./tests/acceptance/fixtures/tests_path/other_test.sh
Running ./tests/acceptance/fixtures/tests_path/other_test.sh
✓ Passed: Assert same
✓ Passed: Assert contains

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Running ./tests/acceptance/fixtures/tests_path/a_test.sh
Running ./tests/acceptance/fixtures/tests_path/a_test.sh
✓ Passed: Assert greater and less than
✓ Passed: Assert empty

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Running ./tests/acceptance/fixtures/test_bashunit_when_log_junit.sh
Running ./tests/acceptance/fixtures/test_bashunit_when_log_junit.sh
✓ Passed: Success
✗ Failed: Failure
Expected '2'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Running ./tests/acceptance/fixtures/test_bashunit_when_log_junit.sh
Running ./tests/acceptance/fixtures/test_bashunit_when_log_junit.sh
✓ Passed: Success
✗ Failed: Failure
Expected '2'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Running ./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh
Running ./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh
✓ Passed: Assert same
✓ Passed: Assert contains
✓ Passed: Assert greater and less than
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Running ./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh
Running ./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh
✓ Passed: Assert same
✓ Passed: Assert contains
✓ Passed: Assert greater and less than
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Running tests/acceptance/fixtures/tests_path/a_test.sh
Running tests/acceptance/fixtures/tests_path/a_test.sh
✓ Passed: Assert greater and less than
✓ Passed: Assert empty
Running tests/acceptance/fixtures/tests_path/other_test.sh
Running tests/acceptance/fixtures/tests_path/other_test.sh
✓ Passed: Assert same
✓ Passed: Assert contains

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Running tests/acceptance/fixtures/tests_path/a_test.sh
Running tests/acceptance/fixtures/tests_path/a_test.sh
✓ Passed: Assert greater and less than
✓ Passed: Assert empty
Running tests/acceptance/fixtures/tests_path/other_test.sh
Running tests/acceptance/fixtures/tests_path/other_test.sh
✓ Passed: Assert same
✓ Passed: Assert contains

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Running ./tests/acceptance/fixtures/test_bashunit_when_report_html.sh
Running ./tests/acceptance/fixtures/test_bashunit_when_report_html.sh
✓ Passed: Success
✗ Failed: Fail
Expected 'to be empty'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Running ./tests/acceptance/fixtures/test_bashunit_when_report_html.sh
Running ./tests/acceptance/fixtures/test_bashunit_when_report_html.sh
✓ Passed: Success
✗ Failed: Fail
Expected 'to be empty'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Running ./tests/acceptance/fixtures/test_bashunit_when_stop_on_failure.sh
Running ./tests/acceptance/fixtures/test_bashunit_when_stop_on_failure.sh
✓ Passed: A success
✗ Failed: B error
Expected '1'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Running ./tests/acceptance/fixtures/test_bashunit_when_stop_on_failure.sh
Running ./tests/acceptance/fixtures/test_bashunit_when_stop_on_failure.sh
✓ Passed: A success
✗ Failed: B error
Expected '1'
Expand Down

0 comments on commit 5a370f7

Please sign in to comment.