File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,38 @@ Help for the various `assert*` functions can be found there.
1919
2020[ bats-assert ] : https://github.com/bats-core/bats-assert
2121
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 redirected 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+ echo " debug message" >&3
37+
38+ # Normal program output (this is what your tests will see and compare)
39+ echo " Hello, World!"
40+ ```
41+
42+ Example run::
43+
44+ ``` none
45+ $ bats hello_world.bats
46+ hello_world.bats
47+ ✓ Say Hi!
48+ debug message
49+ 1 test, 0 failures
50+ ```
51+
52+ This allows you to keep helpful debug output visible while running tests without breaking assertions.
53+
2254## Skipped tests
2355
2456Solving an exercise means making all its tests pass.
You can’t perform that action at this time.
0 commit comments