NUnit 与 MSTest 相比快了多少

发布于 2024-09-25 15:46:00 字数 1022 浏览 0 评论 0原文

Roy Osherove,单元测试的艺术一书的作者,有在博客上评论,NUnit 据称做得更好,其中之一是快得多其中。

我的问题是,如果有的话,能快多少?我们谈论的是一个数量级吗? 10%? 50%?

我问这个是因为目前我无法比较两者。我正在尝试将我的测试项目设置为 双模式,以便我可以在它们之间切换。不幸的是,我在 NUnit 与最新版本的 Microsoft Moles 集成时遇到问题,而且 NUnit 与第三方库冲突(似乎与 log4net 相关)

到目前为止,MSTest 似乎在 Visual Studio 2008 中更容易使用。NUnit 的所有版本问题和兼容性问题(至少对我来说)都引导我选择 MSTest 作为项目的框架(尽管我可能会保留双模式)选项)。 MSTest 的另一个优点是我仍然可以使用大多数 NUnit 断言:

using Assert = NUnit.Framework.Assert;
using Is = NUnit.Framework.Is;

但是...如果 NUnit 中的速度确实快得多,那么我更愿意使用它,尽管存在一些痛点。

最后,VS2010对于MSTest的速度有没有提升

Roy Osherove, author of The Art Of Unit Testing, has commented on a blog that of the many things NUnit supposedly does better, it being much faster is one of them.

My question is how much faster though, if at all? Are we talking an order of magnitude? 10%? 50%?

I'm asking this because for the moment I can't compare the two. I am trying to setup my test project to be in a dual-mode so that I can switch between them. Unfortunately, I am having a problem with NUnit integrating with the latest version of Microsoft Moles, and also NUnit is conflicting with a third party library (appears log4net related).

So far MSTest seems so much easier to use within Visual Studio 2008. All of the version issues and compatibility problems with NUnit (at least for me) is steering me towards choosing MSTest as the framework for the project (though I may keep the dual mode option). Another plus for MSTest is that I can still use most of NUnit asserts with:

using Assert = NUnit.Framework.Assert;
using Is = NUnit.Framework.Is;

But.... If speed is truly much faster in NUnit, then I'd prefer to use it, despite the pain points.

Lastly, has there been any speed improvement in VS2010 for MSTest?

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

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

发布评论

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

评论(2

情栀口红 2024-10-02 15:46:00

我花时间删除了 Microsoft Moles 和处理 log4net 相关问题的生产代码,以便我可以实际比较两者。然后我在 MSTest 2008 和 NUnit 2.5.2 中运行测试。

我发现 MSTest 可以更好地报告每个单独测试的持续时间。如果测试在 NUnit 中足够快,则当单击测试的属性时,TestResults.xml 文件和 GUI 中都会将其记录为 0 秒。尽管如此,我尝试比较所有测试速度的总和,在某些情况下 NUnit 更快,而在其他情况下 MSTest 更快。当其中一个比另一个快时,大约快 30%。

现在,NUnit 看起来肯定更快的是单元测试运行之前的等待时间。当我将 GUI(或控制台)附加到 VS 调试器并运行测试项目时,NUnit 需要大约 3-6 秒的时间来启动和加载,然后才能执行测试。使用 MSTest 需要 15-20 秒。对于 MSTest,无论只有 1 个测试还是 26 个测试,加载时间似乎都是相同的。至于随着测试项目变大,例如在数千个单元测试中,这些等待时间如何扩展,我无法评论其中的差异,尽管我很想知道。

在测试运行时,MSTest 似乎也有一点延迟,可能是为了更新结果窗格。因此,我怀疑当人们说 NUnit 比 MSTest 快得多时,这是因为加载和更新延迟,但实际的测试执行时间似乎非常相似。

Well I took the time to remove Microsoft Moles and the production code that dealt with log4net related issues so that I could actually compare the two. Then I ran tests in both MSTest 2008 and NUnit 2.5.2.

What I found out is that MSTest better reports the duration time of each individual test. If the test is fast enough in NUnit it gets logged as being 0 seconds both in the TestResults.xml file and in the GUI when one clicks on the properties of a test. Nonetheless, I tried to compare the sum of all test speeds and in some cases NUnit is faster and in other cases MSTest is faster. When one is faster than the other it's by about 30%.

Now, where NUnit definitely seems faster is the wait time before the unit tests run. When I attach the GUI (or console) to the VS Debugger, and run the test project, it takes about 3-6 seconds for NUnit to launch and load before the tests can execute. With MSTest it takes between 15-20 seconds. For MSTest it doesn't matter if there is just 1 test or 26, this load time seems to be the same. As regards to how these wait times scale as the test project gets bigger, say in the thousands of unit tests, I can't comment on the difference, though I'd be very interested in knowing.

There also seems to be a little bit of delay in MSTest while the tests are running, perhaps to update the results pane. Thus, I suspect when people say that NUnit is much faster than MSTest, it is because of the loading and updating delays, but the actual test execution time appears to be very similar.

风铃鹿 2024-10-02 15:46:00

我使用过 MSTest 和 NUnit(第一个比后者多),我不能说我注意到它们两者在速度方面有什么大的差异(不要误会我的意思,差异可能存在,我只是没注意到)。

我选择 MSTest 的原因是它与 Visual Studio 的集成,因为它使事情变得更加简单。此外,有一次我在运行几个测试时遇到了一些问题,因为 NUnit 测试在与 MSTests 不同的线程装置中运行。

I have used both MSTest and NUnit (the first more than the latter), and I can't say I noticed any big differences between the two of them regarding speed (don't get me wrong, the difference might be there, I just haven't noticed it).

The reason I choose MSTest is its integration with Visual Studio, as it makes thigns a lot simpler. Additionally, once I had some issues running a couple of tests because the NUnit tests ran in a different thread appartment than MSTests.

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