Automatically show standard output and debug trace messages after a Visual Studio 2008/2010 UnitTest run

If you use the default settings of Microsoft Visual Studio 2008/2010 UnitTesting, the Console.WriteLine and Debug.WriteLine won’t be shown. By double clicking the test, you can see the test details, including the standard output and debug output, but I wanted to see the messages directly after a run. This can be done by right clicking de gridview in the Test Results window and adding the columns Output (StdOut) and Debug Trace.

 

UnitTest class

using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Scripts
{
[TestClass]
public class MainUnitTest
{
[TestMethod]
public void TestMethod1()
{
string result = string.Empty;
result = "This is some debug output";
System.Diagnostics.Debug.WriteLine(result);
result = "This is some standard console output";
System.Console.WriteLine(result);
}
}
}

 

Add columns

image

image

 

Test Result (showing standard console and debug output)

image

 

Details View

image

2 Comments

  1. Alexandru

    And what if I have TestMethod1,TestMethod2 and TestMethod3 ?

    How can I see *all* the console output *concatenated* for all three methods ? Not separately , but together for all three methods.

Leave a Reply

Your email address will not be published. Required fields are marked *