MbUnit 与 NUnit

发布于 2024-09-19 07:05:36 字数 142 浏览 5 评论 0原文

我读到 MbUnit 是 NUnit 的增强版,但我不明白为什么。从我在这里读到的内容来看,我听说 NUnit 比 MbUnit 更受欢迎。主要原因之一是它具有流畅的界面。这是唯一的原因吗?

为什么我应该更喜欢 MbUnit 而不是 NUnit,反之亦然?

I read that MbUnit is NUnit on steroids, but I don't see why. From what I have read on here, I hear that NUnit is more popular over MbUnit. One of the main reasons is because it has a fluent interface. Is this the only reason?

Why should I prefer MbUnit over NUnit, or vice-versa?

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

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

发布评论

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

评论(4

夏日浅笑〃 2024-09-26 07:06:33

MbUnit 插件仅适用于 ReSharper 6(无需任何多余的操作)。因此,如果您使用 Visual Studio 2012 或 Visual Studio 2013,则必须使用开箱即用支持 NUnit 的较新版本的 ReSharper。

而且看起来 MbUnit 和 Gallio 不再受支持。

The MbUnit plugin is available only for ReSharper 6 (without any excess manipulations). So if you use Visual Studio 2012 or Visual Studio 2013 you have to use a newer version of ReSharper which supports NUnit out of the box.

Also it looks like MbUnit and Gallio is no longer supported.

孤星 2024-09-26 07:06:24

对于那些进行研究的人来说,请注意:

来自 MbUnit 的网站:“Gallio 和 MbUnit 目前处于中断状态。”

MbUnit GitHub 帐户显示最近的提交历史记录极其稀疏。

Just a note for those doing research:

From MbUnit's site: "Gallio and MbUnit are currently on hiatus."

The MbUnit GitHub account shows an extremely sparse commit history of late.

梦中的蝴蝶 2024-09-26 07:06:16

NUnit 最初是 JUnit 的一个端口,并且已经存在很长时间了。 MbUnit 是后来出现的,它带来了“生成式”单元测试。这意味着它能够进行单个单元测试并从中生成多个单元测试。执行此操作的一种方法是 [RowTest] 属性。

典型的单元测试不会采用任何参数,而 RowTest 将采用参数并从中生成多个测试。我相信NUnit现在也有了RowTest的概念。

[Test]
[Row(1, 1, 2)]
[Row(2, 2, 4)]
[Row(1, 2, 3)]
public void X_plus_Y_equals_Z(x, y, z)
{
  Assert.AreEqual(z, x+y);
}

这将导致在测试运行器中运行三个测试。还有回滚数据库事务的功能。

NUnit 具有流畅的断言接口,这很好,但并不是真正的卖点。 NUnit 可能还有一些更好的工具支持(ReSharper 的测试运行程序可以开箱即用地使用 NUnit,但需要 MbUnit 的插件)。

最后,您应该选择一个框架并使用它。您学到的技能可以很好地从一个框架移植到另一个框架。

NUnit started as a port of JUnit, and has been around a long time. MbUnit came after the fact, and it brought "generative" unit testing. This means it has the ability to take a single unit test and generate several from it. One way to do this is the [RowTest] attribute.

Where a typical unit test will not take any parameters, a RowTest will take parameters and generate multiple tests from that. I believe that NUnit has the concept of RowTest now as well.

[Test]
[Row(1, 1, 2)]
[Row(2, 2, 4)]
[Row(1, 2, 3)]
public void X_plus_Y_equals_Z(x, y, z)
{
  Assert.AreEqual(z, x+y);
}

This will result in three tests being run in the test runner. There are also features for rolling back database transactions.

NUnit has the fluent interface for assertions, which is nice, but not really a selling point. NUnit probably also has some better tool support (ReSharper's test runner works with NUnit out of the box, but requires plugins for MbUnit).

In the end, you should pick one framework and go with it. The skills you pick up are very portable from one framework to another.

绳情 2024-09-26 07:06:06

尽管 NUnit 现在包含最流行的 MbUnit 高级功能,但 MbUnit 的功能仍然更加丰富,例如:

流畅的界面可能很好,但一般来说它们并不好添加任何新功能。他们只是以不同的方式向程序员展示东西。

NUnit 更受欢迎,因为它首先出现(因此网上有更多关于它的文章,以及更好的工具),并且因为大多数程序员不关心或不需要 MbUnit 提供的高级功能。

Even though NUnit now includes the most popular MbUnit advanced features, MbUnit is still more feature-rich, for example:

Fluent interfaces may be nice, but in general they don't add any new features. They just present things to the programmer in a different way.

NUnit is more popular because it was there first (therefore there are more articles about it on the web, and better tooling), and because most programmers don't care about or need the advanced features that MbUnit offers.

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