ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Code inspection: Console output in Xunit tests

Last modified: 08 April 2024

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. Instead, as the xUnit.net documentation suggests, you should use ITestOutputHelper to capture test output.

ReSharper will warn you about usages of Console.WriteLine inside Fact methods and suggest a quick-fix that will convert these usages to instances of ITestOutputHelper.