3

I've made an "ordered test" in VS 2008 which executes 4 tests. One of the TestMethod tests it runs has several writeline statements, like this:

TestContext.WriteLine("One");
TestContext.WriteLine("Two");
TestContext.WriteLine("Three");

The output I receive in the "Additional Information" of the results shows this output:

One
Two
Three
One
Two
One
Two

I don't think the test method is running multiple times. I think the writeline output is simply being buffered in some bizarre way. How do I fix this?

I get this problem with any test method that has TestContext writeline statements (at least when invoked from an ordered test).

Kamil Budziewski
  • 22,699
  • 14
  • 85
  • 105
Brent Arias
  • 29,277
  • 40
  • 133
  • 234
  • Have you tried trimming down your tests until only the WriteLine calls are left? That’s usually a good way to discover which part is causing this. – Timwi Aug 20 '10 at 01:54
  • If I have only one test, it still has this problem. I don't see how else to interpret the result, other than mstest is buggy or I don't understand the intent of the TestContext.writeline statement. – Brent Arias Aug 20 '10 at 02:06
  • I often use Console.WriteLine in my MSTests. Try that instead. http://stackoverflow.com/questions/4786884/debug-writeline-doesnt-work-from-within-unit-tests – Jason Evans Feb 12 '11 at 11:47

0 Answers0