我在NUnit中有什么可以在MSTest中做的吗?

问题描述:

这个问题已经在许多不同的论坛上以各种形式提出,但是恕我直言,我一直无法找到一个真正能清楚回答的地方,因此,我将重新整理它并再次询问

This question has been asked in various forms in a number of different forums, but, IMHO, I haven't been able to find a place where it's really answered clearly, so I'm going to reframe it and ask it again.

我基本上在Microsoft商店工作.我们使用TFS,并且我们所有的开发人员都具有MSDN订阅,包括VS的Team Suite版本.这样我们就可以访问MSTest.

I work in a basically Microsoft Shop. We use TFS, and all of our developers have MSDN subscriptions including the Team Suite edition of VS. So we have access to MSTest.

我已经阅读了各种NUnit与MSTest的比较,并且开发人员社区似乎绝大多数都选择了NUnit.但是给出的原因似乎从来没有压倒性或令人信服,至少对于我们的情况而言. (NUnit的更新频率更高,NUnit的更新速度更快,NUnit不需要TFS等).

I've read the various NUnit vs. MSTest comparisons, and the developer community seems to pretty much overwhelmingly choose NUnit. But the reasons given don't ever seem to be overwhelming or compelling, at least to our situation. (NUnit is updated more often, NUnit is faster, NUnit doesn't require TFS, etc.)

如果愿意的话,我可以使用NUnit,但是必须捍卫在没有正式支持的情况下使用开源软件.我需要一个相当有说服力的理由.

I can use NUnit if I choose, but the use of open source software without a formal support behind it has to be defended. I need a fairly compelling reason to do so.

使用NUnit优先于MSTest时,我基本上必须回答的问题是:在NUnit中我有什么可以做的事,而我无法在MSTest中做相当的工作?

What I basically have to answer to justify using NUnit in preference to MSTest is this: is there anything that I can do in NUnit that I can't do with comparable effort in MSTest?

  • NUnit包含[TestCase]属性,该属性允许实施参数化测试.这在MSTest中并不存在,但是可以通过可扩展性来完成.
  • MsTest的ExpectedException属性存在一个错误,即即使错误,也不会真正声明预期的消息-测试将通过.
  • NUnit附带有一个Assert.Throws API,以允许在特定代码行而不是整个方法上测试异常. MSTest存在类似的功能(由为NUnit进行测试的同一人实现),但未随MSTest一起提供.
  • NUnit包含开箱即用的流畅版本的Assert API. MSTest具有执行此操作的第三方扩展,但是MSTest并未附带这些扩展.
  • NUnit允许抽象类成为测试夹具(因此您可以继承测试夹具). MsTest允许这样做,但是将抽象类限制为单个程序集.
  • NUnit允许非公共类成为测试装置(最新版本)
  • NUnit完全是出于单元测试的想法而创建的. MSTest是为测试而创建的-也是一些单元测试.
  • NUnit包含PNunit(使用NUnit运行并行测试). MSTest在Visual Studio 2010中添加了此功能,该功能可以通过XML进行配置
    • NUnit contains a [TestCase] attribute that allows implementing parametrized tests. This does not exist out of the box in MSTest - it can be done via extensibility though.
    • MsTest's ExpectedException attribute has a bug where the expected message is never really asserted even if it's wrong - the test will pass.
    • NUnit ships with an Assert.Throws API to allow testing an exception on a specific line of code instead of the whole method. A similar feature exists for MSTest (implemented by the same person who did it for NUnit) but does not ship with MSTest.
    • NUnit contains a fluent version of Assert API out of the box. MSTest has third party extensions that do this, but none are shipped with MSTest.
    • NUnit allows abstract classes to be test fixtures (so you can inherit test fixtures). MsTest allows this but limits abstract classes to a single assembly.
    • NUnit allows non public classes to be test fixtures (as of the latest version)
    • NUnit was created SOLELY for the idea of unit testing. MSTest was created for Testing - and also a bit of unit testing.
    • NUnit contains PNunit (running parallel tests with NUnit). MSTest added this ability in Visual Studio 2010 which is configurable via XML