如何将MSTest的测试执行过程中写Console.Out [英] How to write to Console.Out during execution of an MSTest test

查看:1051
本文介绍了如何将MSTest的测试执行过程中写Console.Out的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文:结果
我们有一些用户报告,在我们的web应用程序的文件上传功能的问题。它只是偶尔发生,并没有任何特殊的图案。我们一直在努力弄明白了很久,加上调试信息的任何地方,我们可以认为它可能会帮助,爬行日志等,但我们一直没能复制或看着办吧。

Context:
We have some users reporting issues with a file upload feature in our web application. It only happens occasionally and without any special pattern. We have been trying to figure it out for a long time, adding debug information anywhere we can think it might help, crawling the logs etc, but we have not been able to reproduce or figure it out.

问题:结果
现在,我尝试使用MSTest的和华廷重复是应该失败了大量的时间(几百)操作重现此。正好有一个关于如何在环测试已经变得远,我想打印出类似这样的线索:

Problem:
I'm now trying to reproduce this by using MSTest and WatiN to repeat the operation that is supposed to fail a large number of times (several hundreds). Just to have a clue about how far in the loop the test has gotten, I want to print something like:

Console.WriteLine(String.Format("Uploaded file, attempt {0} of {1}", i, maxUploads));

这不但是不会出现在输出窗口。现在我知道你会得到的测试结果(以及你输出的Debug.WriteLine 等)的控制台输出,但这不是可用,直到的测试已经完成。而且,由于我与数百重复测试可能需要相当长的一段时间,我想知道它是如何得到远远

This does however not appear in the Output window. Now I know that you'll get the console output in the test results (as well as what you output from Debug.Writeline etc), but this is not available until after the test has finished. And since my test with hundreds of repetitions could take quite some time, I'd like to know how far it has gotten.

问:结果
有没有办法的时候,我可以在输出窗口中的控制台输出的测试执行?

推荐答案

是因为后端code未在测试环境中运行。

The Console output is not appearing is because the backend code is not running in the context of the test.

你可能最好使用 Trace.WriteLine (在System.Diagnostics程序),然后添加跟踪,监听其写入一个文件。

You're probably better off using Trace.WriteLine (In System.Diagnostics) and then adding a trace listener which writes to a file.

这从MSDN 主题显示了这样做的方法。

This topic from MSDN shows a way of doing this.

这篇关于如何将MSTest的测试执行过程中写Console.Out的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆