Any call in my unit tests to either Debug.Write(line)
or Console.Write(Line)
simply gets skipped over while debugging and the output is never printed. Calls to these functions from within classes I'm using work fine.
I understand that unit testing is meant to be automated, but I still would like to be able to output messages from a unit test.
I was also trying to get Debug or Trace or Console or TestContext to work in unit testing.
None of these methods would appear to work or show output in the output window:
Trace.WriteLine("test trace");
Debug.WriteLine("test debug");
TestContext.WriteLine("test context");
Console.WriteLine("test console");
(from comments) In Visual Studio 2012, there is no icon. Instead, there is a link in the test results called Output. If you click on the link, you see all of the WriteLine
.
I then noticed in my Test Results window, after running the test, next to the little success green circle, there is another icon. I doubled clicked it. It was my test results, and it included all of the types of writelines above.