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.
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.
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
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);
}