NUnit 与 Visual Studio 2010 的 MSTest 对比?

发布于 2024-08-23 17:25:42 字数 536 浏览 4 评论 0原文

我意识到有许多较旧的问题解决了 NUnit v MSTest 对于 Visual Studio 2008 以下版本的一般问题(例如 这个)。

微软在其第三个版本中一直致力于把事情做好。对于MSTest来说,就是VS2010。

他们是否使用 MSTest 做到了这一点?您会在新项目中使用它而不是 NUnit 吗?

我的具体关注点:

  • 速度
  • 在 CruiseControl.NET(命令行或 MSBuild 任务)中运行测试的
  • 来自 CC.NET 的代码覆盖率报告
  • 您能否在调试模式下运行 MSTest 测试

(我们使用 ReSharper,因此测试运行程序对我们来说不是问题。我们过去几年我们一直在使用 NUnit,但我们没有 TFS。)

I realise that there are many older questions addressing the general question of NUnit v MSTest for versions of Visual Studio up to 2008 (such as this one).

Microsoft have a history of getting things right in their 3rd version. For MSTest, that is VS2010.

Have they done so with MSTest? Would you use it in a new project in preference to NUnit?

My specific concerns:

  • speed
  • running tests within CruiseControl.NET (either commandline or MSBuild task)
  • code coverage reports from CC.NET
  • can you run MSTest tests in debug mode

(We use ReSharper, so test-runners are not an issue for us. We have used NUnit for the last few years. We do not have TFS.)

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

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

发布评论

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

评论(8

挽梦忆笙歌 2024-08-30 17:25:43

如果您认为您将在 64 位模式下运行测试,请使用 NUnit。 MsTest 仅是 x86。

If you think you'll ever run your tests in 64 bit mode, use NUnit. MsTest is only x86.

黎歌 2024-08-30 17:25:43

两者之间的一个主要区别是 MSTest 每次运行测试时都会生成当前 DLL 的副本。如果您正在进行 TDD 并频繁运行测试,这可能会占用大量硬盘空间。

如果您使用的是 MSTest,则可以在“工具”>“工具”>“工具”中更改此设置。选项>测试工具>>测试执行。在 Visual Studio 2010 中,“旧测试结果的数量限制为”默认设置为 25。我通常将其更改为 1。

One major difference between the two is that MSTest makes a copy of the current DLLs every time it runs a test. If you're doing TDD and running your tests frequently, this can eat up a lot of hard drive space.

If you're using MSTest, you can change this setting in Tools > Options > Test Tools > Test Execution. "Limit number of old Test Results to" is set to 25 by default in Visual Studio 2010. I usually change it to 1.

海螺姑娘 2024-08-30 17:25:43

MSUnit 在与实际执行环境不同的条件下运行测试用例。具体来说,部署的文件与运行实际项目时部署的文件不同。尽管如此,还是有 [DeploymentItem] 属性来指定 MSUnit 应部署哪些文件。因此,如果您的应用程序依赖于任何外部
文件,例如

  • 数据库文件、
  • 数据库配置文件、
  • 应用程序配置文件
  • ...

那么 MSUnit 不是正确的选择,因为 MSUnit 测试永远不会涵盖文件系统在执行环境中的外观。 MSUnit 运行程序将忽略用于部署文件的 Visual Studio 项目文件设置(始终复制、内容等)。因此无法测试这些设置。

MSUnit runs your test cases under conditions that are different from the actual execution environment. Specifically, the deployed files differ from those that are deployed when you run your actual project. Nethertheless, there is the [DeploymentItem]-Attribute to specify which files shall be deployed by MSUnit. So if your application depends on any external
files, such as

  • database files
  • database configuration file
  • application configuration file
  • ...

then MSUnit is not the right choice, because the MSUnit tests never cover what your file system is going to look like in execution environment. The Visual Studio Project File settings for deploying files (Copy always, Content, etc.) are ignored by the MSUnit runner. So those settings cannot be tested.

追星践月 2024-08-30 17:25:42
  • 列表项速度是相同的,但 MsTest 可能会慢一点,因为每次
  • MSBuid 和 CC.Net 都会创建用于测试运行的文件夹,这非常痛苦。你不能在没有 VS 的计算机上运行 MSTest(2010 年不是 100 确定,但 2008 年确实如此)
  • 不确定,抱歉,
  • 是的,你可以,来自 Visual Studio

我的建议如下:如果 NUnit 满足你 - 使用它,忘记 MSTest

  • List item speed is same, but MsTest may be a bit slower because it creates folder for test run every time
  • MSBuid and CC.Net is big pain. You can't run MSTest on computer without VS on it (not 100 sure about 2010, but with 2008 it is so)
  • not sure, sorry
  • yes you can, from visual studio

My recommendation is following: if NUnit satisfies you - use it, forget about MSTest

梓梦 2024-08-30 17:25:42

修正线程上的一些旧信息;

  1. 可以在 2010 年运行 64 位测试
  2. 从 VS2008 开始,不需要 MSTEST 创建目录并在其中复制二进制文件,只需禁用部署,在 2010 年这是默认设置,但您必须在 2008 年设置它
  3. 2010 年 MSTEST 更快,但由于它是一个通用测试框架,也运行负载/Web/UI 测试,因此设计上存在妥协,这会导致速度变慢。 Jamie Cansdale 似乎已成功通过 TestDriven.net 对 MSTEST 支持的最新版本获得性能提升

To correct some old information on the thread;

  1. It IS possible to run 64 bit tests in 2010
  2. From VS2008 forward it is not neccesary to have MSTEST create directories anc opy the binaries in, just disable deployment, in 2010 thats the default but you have to set it in 2008
  3. 2010 MSTEST is faster but as its a generalised test framework that also runs load/web/UI tests there are compromises in the design that will lead to it being slower. Jamie Cansdale appears to have managed to get perf increases with the lastest releases of TestDriven.net's support for MSTEST
浴红衣 2024-08-30 17:25:42

我主要使用过 NUnit、一些 xUnit 和一些 MSTest。它们看起来功能相同,但我不喜欢 MSTest 测试运行程序。它在 Visual Studio 中运行,因此它要么挤满屏幕,要么在另一台显示器上,每次我点击 Visual Studio 时都会受到阻碍。 (我在另一台显示器上运行 NUnit,但每次我聚焦 Visual Studio 时它并没有覆盖该显示器上的所有内容)。需要多次点击才能找出哪些测试失败以及失败的原因。

NUnit 可以在后台运行,直到测试失败,此时它会向您显示有关中断测试的信息。这似乎是保持红/绿/重构顺利进行的理想选择。

I've mainly used NUnit, some xUnit and some MSTest. They seem functionality equivalent, but I don't like the MSTest test runner. It runs in visual studio so it either crowds the screen or is on another monitor getting in the way everytime I tab to visual studio. (I run NUnit on another monitor, but it doesn't cover everything on that monitor everytime I focus visual studio). It takes too many clicks to find out what test failed and why.

NUnit can run in the background until a test fails, at which point it shows you information about the breaking test. This seems like the ideal for keeping red/green/refactor going smoothly.

巴黎夜雨 2024-08-30 17:25:42

没有。关于应用程序域和程序集解析的相同问题仍然存在。我会避免,除非您想要其他功能测试或与团队系统集成的新优点。

Nope. Same issues regarding appdomains and assembly resolving still exist. I would avoid unless you want the new goodness for other functional testing or integration with Team System.

掐死时间 2024-08-30 17:25:42

我对 CruseControl.net 不太了解,但你可以调试测试。我们目前也不使用 TFS,MSTest 正在为我们工作。

I don't know much about CruseControl.net, but you can debug tests. We currently don't use TFS either, and the MSTest is working for us.

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