File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,28 @@ 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
+ When running tests, ` bats ` captures both stdout and stderr for comparison with the expected output.
25
+ 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.
26
+
27
+ To print debug information without affecting the test results, ` bats ` provides file descriptor ** 3** for this purpose.
28
+ Anything written to ` >&3 ` will be shown during the test run but will not be included in the captured output used for assertions.
29
+
30
+ Example:
31
+
32
+ ``` bash
33
+ #! /usr/bin/env bash
34
+
35
+ # This debug message will not interfere with test output comparison
36
+ printf ' %(%T)T -- %s\n' -1 ' debugging message' >&3
37
+
38
+ # Your normal program output
39
+ echo " Hello, World!"
40
+ ```
41
+
42
+ This allows you to keep helpful debug output visible while running tests without breaking assertions.
43
+
22
44
## Skipped tests
23
45
24
46
Solving an exercise means making all its tests pass.
You can’t perform that action at this time.
0 commit comments