4

I've got some unit tests that I run like this:

mstest /testcontainer:"Tests.dll"

Is there any way for me to modify, or add to, the output of this command? I've tried Console.Writeline and this answer, but neither seemed to work.

Community
  • 1
  • 1
ConditionRacer
  • 4,418
  • 6
  • 45
  • 67

2 Answers2

3

Use Console.Writeline as you already do, and run MSTest with the /detail switch:

MSTest /testcontainer:"Tests.dll" /detail:stdout

Code

[TestMethod]
public void TestMethod1()
{
    Console.WriteLine("Output to console...");
}

Output

enter image description here

chaliasos
  • 9,659
  • 7
  • 50
  • 87
0

I haven't tried this from the console, but usually I use the TestContext in Visual Studio. You can use it like String.Format as well. In Visual Studio you can then go to view test results and see the output.

   public TestContext TestContext { get; set; }

   [TestMethod]
   public void MyTestMethod()
   {
       int value = 5;
       TestContext.WriteLine("This is my output for the test: {0}", value);
   }
JamWils
  • 785
  • 7
  • 17