Add custom message to unit test result

Rush Frisby picture Rush Frisby · Jan 4, 2011 · Viewed 34.5k times · Source

Is there a way I can add a custom message to the result of a test method? I want to put a stopwatch on part of the code to see how long its running. I don't need to test that it's running within a certain time frame, just want to see in the result window what the elapsed time was.

Answer

vcsjones picture vcsjones · Jan 4, 2011

Assuming you are using MSTest, you can use

System.Diagnostics.Trace.WriteLine("Hello World");

To output whatever you'd like. It will show up in the full results of the test runner.