@@ -42,12 +42,14 @@ Running tests in tests/test_bash_unit.sh
42
42
Running test_assert_equals_fails_when_not_equal... SUCCESS
43
43
Running test_assert_equals_succeed_when_equal... SUCCESS
44
44
Running test_assert_fail_fails... SUCCESS
45
+ Running test_assert_fail_shows_stdout_stderr_on_failure... SUCCESS
45
46
Running test_assert_fail_succeeds... SUCCESS
46
47
Running test_assert_fails... SUCCESS
47
48
Running test_assert_not_equals_fails_when_equal... SUCCESS
48
49
Running 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
50
51
Running test_assert_status_code_fails... SUCCESS
52
+ Running test_assert_status_code_shows_stdout_stderr_on_failure... SUCCESS
51
53
Running test_assert_status_code_succeeds... SUCCESS
52
54
Running test_assert_succeeds... SUCCESS
53
55
Running test_bash_unit_runs_teardown_even_in_case_of_failure... SUCCESS
@@ -82,12 +84,14 @@ Running tests in tests/test_bash_unit.sh
82
84
Running test_assert_equals_fails_when_not_equal... SUCCESS
83
85
Running test_assert_equals_succeed_when_equal... SUCCESS
84
86
Running test_assert_fail_fails... SUCCESS
87
+ Running test_assert_fail_shows_stdout_stderr_on_failure... SUCCESS
85
88
Running test_assert_fail_succeeds... SUCCESS
86
89
Running test_assert_fails... SUCCESS
87
90
Running test_assert_not_equals_fails_when_equal... SUCCESS
88
91
Running 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
90
93
Running test_assert_status_code_fails... SUCCESS
94
+ Running test_assert_status_code_shows_stdout_stderr_on_failure... SUCCESS
91
95
Running test_assert_status_code_succeeds... SUCCESS
92
96
Running test_assert_succeeds... SUCCESS
93
97
Running test_fail_fails... SUCCESS
@@ -138,7 +142,7 @@ Evaluate *assertion* and fails if *assertion* fails.
138
142
139
143
* assertion* fails if its evaluation returns a status code different from 0.
140
144
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.
142
146
143
147
``` bash
144
148
test_assert_fails () {
@@ -193,22 +197,19 @@ code() {
193
197
test_code_write_appropriate_content_in_the_file () {
194
198
code
195
199
196
- assert " diff <(echo 'this is cool') /tmp/the_file >&2 "
200
+ assert " diff <(echo 'this is cool') /tmp/the_file"
197
201
}
198
202
```
199
203
200
204
``` output
201
205
Running 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
206
210
doc:8:test_code_write_appropriate_content_in_the_file()
207
211
```
208
212
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
-
212
213
## * assert_fail*
213
214
214
215
assert_fail <assertion> [message]
@@ -217,7 +218,7 @@ Asserts that *assertion* fails. This is the opposite of *assert*.
217
218
218
219
* assertion* fails if its evaluation returns a status code different from 0.
219
220
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 .
221
222
222
223
``` bash
223
224
code () {
@@ -240,6 +241,7 @@ test_code_does_not_write_this_in_the_file() {
240
241
``` output
241
242
Running test_code_does_not_write_cool_in_the_file... FAILURE
242
243
should not write 'cool' in /tmp/the_file
244
+ out> not so cool
243
245
doc:8:test_code_does_not_write_cool_in_the_file()
244
246
Running test_code_does_not_write_this_in_the_file... SUCCESS
245
247
```
@@ -252,6 +254,8 @@ Checks for a precise status code of the evaluation of *assertion*.
252
254
253
255
It may be usefull if you want to distinguish between several error conditions in your code.
254
256
257
+ In case of failure, the standard output and error of the evaluated * assertion* is displayed. The optional message is also displayed.
258
+
255
259
``` bash
256
260
code () {
257
261
exit 23
@@ -264,7 +268,7 @@ test_code_should_fail_with_code_25() {
264
268
265
269
``` output
266
270
Running test_code_should_fail_with_code_25... FAILURE
267
- expected [25] but was [23]
271
+ expected status code 25 but was 23
268
272
doc:6:test_code_should_fail_with_code_25()
269
273
```
270
274
0 commit comments