0

I'm using MSTest to run some tests (in C#). One of the routines I'm testing creates a new process and that process often dumps some output stdout. I'd like to capture that output in the test. While it isn't important to see if the test failed, it is very helpful in figuring out why the test failed. How can I do this?

Some details. Unfortunately, I can't touch the code that is creating the process. Worse, it is C++, and it is being called via a C++/CLI wrapper. If I create a .NET console app (in C#) then the stdout of the subprocess I want to capture does appear in the window of the console app when it makes the call. When I run the same code in the MSTest context the sub-process creation pops up a new window, and the subprocess dumps its output in that window. It is that output I'd like to capture if at all possible.

Many thanks!

Gordon
  • 3,012
  • 2
  • 26
  • 35

1 Answers1

0

If you double click on the test result once it finish,you should see a report page containing the stdout too.. then you can see here Redirecting stdout of one process object to stdin of another how to redirect your child process stdout and just mirror this in the stdout of the test ( ie call Console.Write() )

Community
  • 1
  • 1
Felice Pollano
  • 32,832
  • 9
  • 75
  • 115
  • Thanks for the suggestion! Unfortunately, that won't work - I don't have control over the Process create command. There is some sort of difference between a windows process and a console process, and it has to do with stdout. So what I need to do is a) detect if there is a valid stdout. If there is do nothing. b) If there isn't create it, and have it read by a thread, and c) everything read should be copied to Console.WriteLine. – Gordon Jan 18 '11 at 23:45