Code Inspection: Console output in Xunit tests | ReSharper
www.jetbrains.com › help › resharperMar 8, 2021 · Code Inspection: Console output in Xunit tests. You can suppress this inspection to ignore specific issues, change its severity level to make the issues less or more noticeable, or disable it altogether. Output of unit tests is often printed using Console.WriteLine. However, this may not work correctly with xUnit.net 2.x, because parallelization is turned on by default there.
c# - How to do unit test console output with xUnit.net ...
stackoverflow.com › questions › 11019555Jun 13, 2012 · In real application, you pass it Console.Out to print to system console. In test, you simply use fake writer (for example StringWriter based on StringBuilder ): const int NumberToPrint = 5; var content = new StringBuilder(); var writer = new StringWriter(content); var sut = new Test(writer, NumberToPrint); sut.PrintNumber(); var actualOutput = content.ToString(); Assert.AreEqual(actualOutput, "Number: 5");
Capturing Output > xUnit.net
xunit.net › docs › capturing-outputIn order to assist in debugging failing test (especially when running them on remote machines without access to a debugger), it can often be helpful to add diagnostic output that is separate from passing or failing test results. xUnit.net offers two such methods for adding output, depending on what kind of code you're trying to diagnose. If you used xUnit.net 1.x, you may have previously been writing output to Console, Debug, or Trace.