using Xunit; public class MyTests { private readonly ITestOutputHelper output; public MyTests(ITestOutputHelper output) { this.output = output; } [Fact] public void Test_Method() { output.WriteLine("This is a test output message."); Assert.True(true); } }
using Xunit; public class MyTests { private readonly ITestOutputHelper output; public MyTests(ITestOutputHelper output) { this.output = output; } [Fact] public void Test_Method() { var expected = 2; var actual = MyMath.AddIntegers(1, 2); output.WriteLine($"Expected Result : {expected}"); output.WriteLine($"Actual Result : {actual}"); Assert.Equal(expected, actual); } }In this example, we are using ITestOutputHelper to write both the expected and actual test results to the test runner's output channel in case of a test failure. We are using the Assert.Equal method to compare the expected and actual results of the AddIntegers method from the MyMath class. ITestOutputHelper is a part of the Xunit.Abstractions package library.