How to output log in MS Unit Testing Framework VS 2010

mstest, unit-testing, visual-studio-2010

Solution

Make sure your test class contains the following:

private TestContext testContextInstance;

/// <summary>
/// Gets or sets the test context which provides
/// information about and functionality for the current test run.
/// </summary>
public TestContext TestContext
{
    get
    {
        return testContextInstance;
    }
    set
    {
        testContextInstance = value;
    }
}

Then you can call:

this.testContextInstance.WriteLine("Hello World");

Problem

I am trying to log some information while the unit test is running in MS Unit Testing Framework VS 2010. I tried Trace.WriteLine, Console.WriteLine and Debug.WriteLine but I am not able to see the output in the output window. Any idea how to do it? Thanks in advance

Original source