开发者

Capturing stdout from a subprocess run during a test in mstest

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开发者_JAVA技巧 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!


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() )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜