如何在VS2010的测试结果窗口中查看单元测试的输出?
我是单元测试的新手,我想查看测试的输出。
假设我正在测试某些对象是否存在:
List<MyObject> actual = target.GetMyObjects();
Assert.IsTrue(actual.Count > 0, String.Format("{0} objectes fetched", actual.Count));
在 VS2010 的“测试结果”窗口中,我想查看“String.Format("{0} objectes fetched",actual.Count)”的结果。
这可能吗?
I'm new to unit testing and I want to see output from my tests.
Let's assume I'm testing for the existance of certain objects:
List<MyObject> actual = target.GetMyObjects();
Assert.IsTrue(actual.Count > 0, String.Format("{0} objectes fetched", actual.Count));
In the 'Test Result' window in VS2010 I want to see the result of "String.Format("{0} objectes fetched", actual.Count)".
Is that possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
找到了:
我将
Output(StdOut)
列添加到“测试结果”窗口。我将测试方法的结尾更改为:
Found it:
I added the column
Output(StdOut)
to the Test Result window.I changed the end of my test method to this:
是的,这是可能的。如果测试失败,您在第二个参数中输入的任何消息都可能有用。在您的情况下,如果计数值对于调试错误很重要,请继续使用它。
即使测试失败或成功,稍后在调试时会自动进行,此信息可能会有所帮助。 http://www.creatingsoftware.net/2010 /03/best-practices-for-assert-statements-in.html
Yes this is possible. If the test fails whatever message that you put in the second parameter might be useful.In your case if the count value is important for you to debug the error go ahead with it.
Even if the failing or succeeding the test is automated later when debugging this information might be helpful. http://www.creatingsoftware.net/2010/03/best-practices-for-assert-statements-in.html
或者,您可以使用
然后当您运行测试时,您会在成功/失败窗口中获得一个超链接“输出”,其中将显示所有调试消息。
显然你需要添加
Dom
Alternatively you could use
And then when you run your test, you get a hyperlink "Output" in the success/fail window which will show all of your debug messages.
Obviously you need to add
Dom
不,您不想看到输出。
每个单元测试必须成功或失败。这使得测试运行者能够将测试结果聚合成单个失败/通过测试结果。如果需要人工检查,单元测试的意义就丢失了——它必须自动化。
No, you don't want to see the output.
Each unit test must either succeed or fail. This enables the test runner to aggregate the test results into a single Fail/Pass test result. If human inspection is required, the point of unit testing is lost - it must be automated.