@@ -42,12 +42,14 @@ Running tests in tests/test_bash_unit.sh
4242Running test_assert_equals_fails_when_not_equal... SUCCESS
4343Running test_assert_equals_succeed_when_equal... SUCCESS
4444Running test_assert_fail_fails... SUCCESS
45+ Running test_assert_fail_shows_stdout_stderr_on_failure... SUCCESS
4546Running test_assert_fail_succeeds... SUCCESS
4647Running test_assert_fails... SUCCESS
4748Running test_assert_not_equals_fails_when_equal... SUCCESS
4849Running test_assert_not_equals_succeeds_when_not_equal... SUCCESS
49- Running test_assert_show_stderr_when_failure ... SUCCESS
50+ Running test_assert_shows_stdout_stderr_on_failure ... SUCCESS
5051Running test_assert_status_code_fails... SUCCESS
52+ Running test_assert_status_code_shows_stdout_stderr_on_failure... SUCCESS
5153Running test_assert_status_code_succeeds... SUCCESS
5254Running test_assert_succeeds... SUCCESS
5355Running test_bash_unit_runs_teardown_even_in_case_of_failure... SUCCESS
@@ -82,12 +84,14 @@ Running tests in tests/test_bash_unit.sh
8284Running test_assert_equals_fails_when_not_equal... SUCCESS
8385Running test_assert_equals_succeed_when_equal... SUCCESS
8486Running test_assert_fail_fails... SUCCESS
87+ Running test_assert_fail_shows_stdout_stderr_on_failure... SUCCESS
8588Running test_assert_fail_succeeds... SUCCESS
8689Running test_assert_fails... SUCCESS
8790Running test_assert_not_equals_fails_when_equal... SUCCESS
8891Running test_assert_not_equals_succeeds_when_not_equal... SUCCESS
89- Running test_assert_show_stderr_when_failure ... SUCCESS
92+ Running test_assert_shows_stdout_stderr_on_failure ... SUCCESS
9093Running test_assert_status_code_fails... SUCCESS
94+ Running test_assert_status_code_shows_stdout_stderr_on_failure... SUCCESS
9195Running test_assert_status_code_succeeds... SUCCESS
9296Running test_assert_succeeds... SUCCESS
9397Running test_fail_fails... SUCCESS
@@ -138,7 +142,7 @@ Evaluate *assertion* and fails if *assertion* fails.
138142
139143* assertion* fails if its evaluation returns a status code different from 0.
140144
141- In case of failure, the standard error of the evaluated * assertion* is displayed. The optional message is also displayed.
145+ In case of failure, the standard output and error of the evaluated * assertion* is displayed. The optional message is also displayed.
142146
143147``` bash
144148test_assert_fails () {
@@ -193,22 +197,19 @@ code() {
193197test_code_write_appropriate_content_in_the_file () {
194198 code
195199
196- assert " diff <(echo 'this is cool') /tmp/the_file >&2 "
200+ assert " diff <(echo 'this is cool') /tmp/the_file"
197201}
198202```
199203
200204``` output
201205Running test_code_write_appropriate_content_in_the_file... FAILURE
202- 1c1
203- < this is cool
204- ---
205- > not so cool
206+ out> 1c1
207+ out> < this is cool
208+ out> ---
209+ out> > not so cool
206210doc:8:test_code_write_appropriate_content_in_the_file()
207211```
208212
209- Note how we redirect standard output of * diff* to * stderr* . This is because * assert*
210- will only display * stderr* in case of failure but * diff* displays differences on * stdout* .
211-
212213## * assert_fail*
213214
214215 assert_fail <assertion> [message]
@@ -217,7 +218,7 @@ Asserts that *assertion* fails. This is the opposite of *assert*.
217218
218219* assertion* fails if its evaluation returns a status code different from 0.
219220
220- If the evaluated expression does not fail, then * assert_fail* will fail and display an optional message.
221+ If the evaluated expression does not fail, then * assert_fail* will fail and display the standard output and error of the evaluated * assertion * . The optional message is also displayed .
221222
222223``` bash
223224code () {
@@ -240,6 +241,7 @@ test_code_does_not_write_this_in_the_file() {
240241``` output
241242Running test_code_does_not_write_cool_in_the_file... FAILURE
242243should not write 'cool' in /tmp/the_file
244+ out> not so cool
243245doc:8:test_code_does_not_write_cool_in_the_file()
244246Running test_code_does_not_write_this_in_the_file... SUCCESS
245247```
@@ -252,6 +254,8 @@ Checks for a precise status code of the evaluation of *assertion*.
252254
253255It may be usefull if you want to distinguish between several error conditions in your code.
254256
257+ In case of failure, the standard output and error of the evaluated * assertion* is displayed. The optional message is also displayed.
258+
255259``` bash
256260code () {
257261 exit 23
@@ -264,7 +268,7 @@ test_code_should_fail_with_code_25() {
264268
265269``` output
266270Running test_code_should_fail_with_code_25... FAILURE
267- expected [25] but was [23]
271+ expected status code 25 but was 23
268272doc:6:test_code_should_fail_with_code_25()
269273```
270274
0 commit comments