Today I was debugging a test at commandline with dotnet core and was suprised to see that when using xunit Console.Write messages were not bubbled up to the command line.

After a little research i discoverd that xunit wants you to use ITestOutputHelper

So to do that in file that contains my test I add the following dependencies

using Xunit.Abstractions;

I then add a private variable:

private readonly ITestOutputHelper output;

The in the constuctor of the test class I add:

public Testing(ITestOutputHelper output){
            this.output = output;
        }

Finally in the test I add a call to the output:

 output.WriteLine("The third Element is {0}", thirdelement);

You will the find when you run the test from the commandline using dotnet test the output is displayed when the test fails if the test passes output is not reported.