0

We have several tests which have been switched to using XUnit 3. We have an assembly-level

[assembly: CaptureConsole(CaptureOut = true, CaptureError = true)]

and we have several "more integration than unit tests" that write to the console. Out tests inject the ITestOutputHelper. We try to inspect the Output property of the field but we have the impression that not all tests capture the correct output.

We have noticed that XUnit calls the Console.SetOut() method and we are wondering if it is a safe assumption that each test instance will get its own private copy of that internal instance.

In Xunit 3, tests are OutputType=Exe and we wonder if several tests re-use the same process and therefore the same Console.Out. (We have also tried to disable parallel tests but even then some tests capture the wrong output).

0

1 Answer 1

1

It turns out that [CaptureConsole] doesn't capture all output. It only captures output to the console for code running in the same thread as the unit test. If you use a TestHost then the ultimate code in the controllers runs in a separate thread and that console output is not captured. Created a documentation issue in github.com/xunit/xunit/issues/3399

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.