Skip to content

Commit 0bd2a08

Browse files
committed
assert_print_stdout_stderr
Update corresponding documentation.
1 parent 9790bed commit 0bd2a08

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

README.md

+17-13
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ Running tests in tests/test_bash_unit.sh
4242
Running test_assert_equals_fails_when_not_equal... SUCCESS
4343
Running test_assert_equals_succeed_when_equal... SUCCESS
4444
Running test_assert_fail_fails... SUCCESS
45+
Running test_assert_fail_shows_stdout_stderr_on_failure... SUCCESS
4546
Running test_assert_fail_succeeds... SUCCESS
4647
Running test_assert_fails... SUCCESS
4748
Running test_assert_not_equals_fails_when_equal... SUCCESS
4849
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
5051
Running test_assert_status_code_fails... SUCCESS
52+
Running test_assert_status_code_shows_stdout_stderr_on_failure... SUCCESS
5153
Running test_assert_status_code_succeeds... SUCCESS
5254
Running test_assert_succeeds... SUCCESS
5355
Running test_bash_unit_runs_teardown_even_in_case_of_failure... SUCCESS
@@ -82,12 +84,14 @@ Running tests in tests/test_bash_unit.sh
8284
Running test_assert_equals_fails_when_not_equal... SUCCESS
8385
Running test_assert_equals_succeed_when_equal... SUCCESS
8486
Running test_assert_fail_fails... SUCCESS
87+
Running test_assert_fail_shows_stdout_stderr_on_failure... SUCCESS
8588
Running test_assert_fail_succeeds... SUCCESS
8689
Running test_assert_fails... SUCCESS
8790
Running test_assert_not_equals_fails_when_equal... SUCCESS
8891
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
9093
Running test_assert_status_code_fails... SUCCESS
94+
Running test_assert_status_code_shows_stdout_stderr_on_failure... SUCCESS
9195
Running test_assert_status_code_succeeds... SUCCESS
9296
Running test_assert_succeeds... SUCCESS
9397
Running 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
144148
test_assert_fails() {
@@ -193,22 +197,19 @@ code() {
193197
test_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
201205
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
206210
doc: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
223224
code() {
@@ -240,6 +241,7 @@ test_code_does_not_write_this_in_the_file() {
240241
```output
241242
Running test_code_does_not_write_cool_in_the_file... FAILURE
242243
should not write 'cool' in /tmp/the_file
244+
out> not so cool
243245
doc:8:test_code_does_not_write_cool_in_the_file()
244246
Running 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

253255
It 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
256260
code() {
257261
exit 23
@@ -264,7 +268,7 @@ test_code_should_fail_with_code_25() {
264268

265269
```output
266270
Running test_code_should_fail_with_code_25... FAILURE
267-
expected [25] but was [23]
271+
expected status code 25 but was 23
268272
doc:6:test_code_should_fail_with_code_25()
269273
```
270274

0 commit comments

Comments
 (0)