Skip to content

Commit 71b5fcc

Browse files
committed
xunit/xunit#3399: Document async-local nature of output capture in v3
1 parent 8407f16 commit 71b5fcc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

site/docs/capturing-output.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ Similarly, the `CaptureTrace` attribute will capture output to be `Trace` and `D
4343

4444
Also bear in mind that `Debug` output is only captured when running a Debug build of your unit tests; when running a Release build, all usage of `Debug` is turned off, including output.
4545

46+
> [!NOTE]
47+
> Both the console and the trace system are process-wide shared resources. xUnit.net v3 uses an async-local context (`TestContext`) to be able to associate the current thread with the associated test. This allows test parallelization while routing the console and trace output to their appropriate tests.
48+
>
49+
> If you write console or trace output to a thread that is not associated with a test (such as a background worker thread created by your test or production code), then that output will silently discarded as there is no test to associate the output to.
50+
4651
xUnit.net v3 tests may also continue to use `ITestOutputHelper` as described below.
4752

4853
### xUnit.net v2

0 commit comments

Comments
 (0)