Posted By

pckujawa on 08/04/10


testing trace

Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


Add the Console as a TraceListener (to have Trace messages treated as Console output)

 / Published in: C#

This is particularly useful for unit testing, but you could do it anywhere in your code.

  1. //Use TestInitialize to run code before running each test
  2. [TestInitialize()]
  3. public void MyTestInitialize()
  4. {
  5. Trace.Listeners.Add(new ConsoleTraceListener());
  6. }
  8. // Implementation
  9. Trace.WriteLine("Tracing my program execution");

Report this snippet  

You need to login to post a comment.