VS2010单元测试,“测试结果错误消息"字段始终为空 [英] VS2010 Unit Test, Test Results Error Message field always blank

查看:107
本文介绍了VS2010单元测试,“测试结果错误消息"字段始终为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将消息字符串添加到我的断言中,但是它们未显示在单元测试测试结果错误消息"字段中.

I add message strings to my Asserts, but they do not show up in Unit Test Test Results Error Message field.

我捕获到异常e并使用Assert.Fail(e.message);并且静态消息未显示在测试结果错误消息"字段中.

I catch Exceptions e and use Assert.Fail(e.message); and still message does not show up in Test Results Error Message field.

我使用Console.Writeline和Debug.Writeline,它们都不显示在Output.Debug窗口中.

I use Console.Writeline and Debug.Writeline and neither show up in Output.Debug window.

如何获取断言消息以显示在单元测试测试结果错误消息中?场?

How can I get Assert message to show up in Unit Test Test Results Error Message  field?

没有指南或示例.

我正在使用有序测试,以便测试按我指定的顺序运行.

I am using Ordered Tests so that the tests run in the order that I specify.

推荐答案

Hello DonBaechtel,

感谢您在MSDN论坛中发帖.

如果您正在执行有序测试,则只能在测试结果"窗口中获取失败/通过"结果.要查看单个单元测试的详细结果,需要在运行后单击查看测试结果详细信息".

If you are doing ordered test, then you can only get the Failed/Pass result in the Test Results window. To view detailed results of individual unit test, you need to click the View Test Results Details after run.

我尝试了以下单元测试:

[TestMethod]

公共无效性Test1(){

尝试{

Assert.AreEqual(2,3);

}

catch(AssertFailedException e)

{

Assert.Fail(错误消息")

}

}

单独运行后,测试结果错误消息"字段中将显示"Assert.Fail failed"和"ERROR MESSAGE".您可以在测试结果错误消息"字段中获得断言"消息.

但是,如果您使用有序测试,即使在详细的测试结果中也不会看到错误消息.恐怕您必须运行单个单元测试才能在错误消息"字段中看到断言"消息.

最诚挚的问候,


这篇关于VS2010单元测试,“测试结果错误消息"字段始终为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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