如何使 VS Unit Test 显示来自 UnitTestAssertException 以外的异常的错误消息?

发布于 2024-09-26 05:54:57 字数 336 浏览 1 评论 0原文

我正在使用 VS 单元测试框架起订量

当起订量验证失败时,我会收到 Moq.MockException。在“测试结果”窗口中,它没有显示异常中的有用消息,而是仅显示“测试方法 XXX 抛出异常:...”

是否有方法告诉 VS 单元测试框架始终显示给定异常的消息类型(如 Moq.MockException)?

I'm using VS Unit Testing Framework and Moq.

When a Moq verification fails, I'll get a Moq.MockException. In the Test Results window, instead of showing the helpful message inside the exception, it just says "Test method XXX threw exception: ..."

Is there a way to tell the VS Unit Test framework always display the message of exceptions of a given type (like Moq.MockException)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空城缀染半城烟沙 2024-10-03 05:54:57

简短的回答是:不。您必须在 MSTest 中打开“测试详细信息”窗口(顺便说一句,这也是我认为 MSTest 不是进行测试驱动开发的最佳选择的众多原因之一。 ..)。

无论如何,有两种可能的方法可以实现此目的(至少我知道):

  1. 使用 ReSharper 来运行你的测试。
  2. 使用免费的 Gallio 自动化平台来运行您的测试。

呵呵!
托马斯

The short answer is: No. You have to open the Test Details window for that in MSTest (btw. that's one of many reasons why I think MSTest is not the best choice for doing Test-driven development...).

Anyway, there are two possible ways to achieve this (at least that I know of):

  1. Use ReSharper to run your tests.
  2. Use the free Gallio automation platform to run your tests.

HTH!
Thomas

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文