Skip to content

Commit c9de0bf

Browse files
authored
Merge pull request #27 from rcastagnet/master
FIX issue #26
2 parents f9b38b5 + b0ec89a commit c9de0bf

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Running test_fake_echo_stdin_when_no_params... SUCCESS
8282
Running test_fake_exports_faked_in_subshells... SUCCESS
8383
Running test_fake_transmits_params_to_fake_code... SUCCESS
8484
Running test_one_test_should_stop_after_first_assertion_failure... SUCCESS
85+
Running test_one_test_should_stop_when_assert_fails... SUCCESS
8586
Running test_run_all_file_parameters... SUCCESS
8687
Running test_run_all_tests_even_in_case_of_failure... SUCCESS
8788
Running test_run_only_tests_that_match_pattern... SUCCESS
@@ -112,6 +113,7 @@ Running test_assert_status_code_succeeds... SUCCESS
112113
Running test_assert_succeeds... SUCCESS
113114
Running test_fail_fails... SUCCESS
114115
Running test_one_test_should_stop_after_first_assertion_failure... SUCCESS
116+
Running test_one_test_should_stop_when_assert_fails... SUCCESS
115117
```
116118

117119
# How to write tests

bash_unit

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ _assert_expression() {
8383
then
8484
fail "$(eval echo $message)" $stdout $stderr
8585
fi
86-
)
86+
) || exit $?
8787
}
8888

8989
assert_equals() {

tests/test_bash_unit.sh

+7
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,13 @@ test_one_test_should_stop_after_first_assertion_failure() {
225225

226226
}
227227

228+
test_one_test_should_stop_when_assert_fails() {
229+
#FIX https://github.com/pgrange/bash_unit/issues/26
230+
assert_equals "before failure" \
231+
"$($BASH_UNIT <(echo 'test_fail() { echo "before failure" >&2 ; assert false ; echo "after failure" >&2 ; }') 2>&1 >/dev/null)"
232+
233+
}
234+
228235
test_bash_unit_changes_cwd_to_current_test_file_directory() {
229236
assert "ls ../tests/$(basename $BASH_SOURCE)" \
230237
"bash_unit should change current working directory to match the directory of the currenlty running test"

0 commit comments

Comments
 (0)