Tag Archives: Visual Studio

Output text to console, xUnit 2.x / Visual Studio 2013

Latest version of xUnit (2.x) eats up any Debug/Trace messages. Use ITestOutputHelper to log to the output section of the test result pane.

using Xunit;
using Xunit.Abstractions;
 
namespace XUnitTestBox
{
    public class OutputTest
    {
        private readonly ITestOutputHelper _output;
 
        public OutputTest(ITestOutputHelper output)
        {
            _output = output;
        }
 
        [Fact]
        public void MethodWithSomeOutputTest()
        {
            _output.WriteLine("Some dummy output text");
            Assert.True(true);
        }
    }
}