File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,42 @@ Help for the various `assert*` functions can be found there.
19
19
20
20
[ bats-assert ] : https://github.com/bats-core/bats-assert
21
21
22
+ ## Debugging output
23
+
24
+ ``` exercism/caution
25
+ This works locally with `bats`, but **not** in the Exercism online editor.
26
+ ```
27
+
28
+ When running tests, ` bats ` captures both stdout and stderr for comparison with the expected output.
29
+ If you print debug messages to stdout (` echo ` ) or stderr (` >&2 ` ), they will be included in the captured output and may cause the test to fail.
30
+
31
+ To print debug information without affecting the test results, ` bats ` provides file descriptor ** 3** for this purpose.
32
+ Anything redirected to ` >&3 ` will be shown during the test run but will not be included in the captured output used for assertions.
33
+
34
+ Example:
35
+
36
+ ``` bash
37
+ #! /usr/bin/env bash
38
+
39
+ # This debug message will not interfere with test output comparison
40
+ echo " debug message" >&3
41
+
42
+ # Normal program output (this is what your tests will see and compare)
43
+ echo " Hello, World!"
44
+ ```
45
+
46
+ Example run:
47
+
48
+ ``` none
49
+ $ bats hello_world.bats
50
+ hello_world.bats
51
+ ✓ Say Hi!
52
+ debug message
53
+ 1 test, 0 failures
54
+ ```
55
+
56
+ This allows you to see helpful debug output without affecting the tests.
57
+
22
58
## Skipped tests
23
59
24
60
Solving an exercise means making all its tests pass.
You can’t perform that action at this time.
0 commit comments