最喜欢的 .NET 单元测试框架
我使用 NUnit 已有几年了。 我尝试过 MBUnit 以及 Zenebug 和 XUnit 一段时间,但我一直回到 NUnit。
您最喜欢/最常用的单元测试框架是什么? 你能解释一下你为什么使用它吗?
I've been using NUnit for a few years. I've tried MBUnit for a short while as well as Zenebug and XUnit but I keep coming back to NUnit.
What is your favorite/most used Unit test Framework? Can you explain why you're using it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(15)
努尼特为了胜利!! 它简单且易于实施。 没有混乱,没有大惊小怪。
Nunit for the win!! It is simple and easy to implement. No mess, no fuss.
xUnit.net,但我很难说是公正的。 :)
为什么我使用它: http://www.codeplex.com /xunit/Wiki/View.aspx?title=WhyDidWeBuildXunit
xUnit.net, but I'm hardly unbiased. :)
Why I use it: http://www.codeplex.com/xunit/Wiki/View.aspx?title=WhyDidWeBuildXunit
MbUnit
我喜欢它处理报告的方式,并且我期待着即将推出的一些功能听说过,例如与 JsUnit 集成。
MbUnit
I like the way it handles reports, and I'm looking forward to some of the upcoming features I've heard about, such as integration with JsUnit.
我已经使用 nUnit 多年,但当我们迁移到 VS2008 和 TFS 2008(使用 TeamBuild)时,我们决定尝试 MSTest。 没有什么大的抱怨...我们真的很喜欢它与 IDE 以及 CI 构建服务器的集成。
我们正在尝试的一项新产品看起来具有巨大的潜力,它是 Microsoft Research 的另一个附加组件,名为 Pex(需要 VS2008)。 正如他们所说:“Pex 通过基于动态符号执行的自动探索性测试,从手写的参数化单元测试生成单元测试。” 我的说法是:这个东西对你的单元测试和目标代码以及 codegen 的单元测试进行静态分析,以实现超高的代码覆盖率(如果你手工完成,这通常是不切实际的)。
I've used nUnit for years, but when we moved to VS2008 and TFS 2008 (using TeamBuild) we decided to try MSTest. No huge complaints there... we really like how well it integrates with the IDE as well as the CI build server.
One new thing we're trying which looks to have awesome potential is another add-on from Microsoft Research called Pex (requires VS2008). As they put it: "Pex generates unit tests from hand-written parameterized unit tests through automated exploratory testing based on dynamic symbolic execution." The way I put it is: this thing does static analysis on your unit test and target code and codegen's unit tests to achieve super high code coverage (which is often impractical if you're doing it by hand).
Gallio 看起来一旦变得更加稳定(目前是 Alpha )。
它不仅仅是一个测试框架,而且是一个测试自动化平台,因此它可以与许多现有的测试框架(MbUnit、NUnit、xUnit.net)配合使用,而且可以完全扩展,具有许多内置的附加功能,例如在许多格式和代码分析工具。
我还听说它将能够
编辑:它现在确实已经超出了 alpha 版本。 我们在我们公司尝试过,但我们真的很讨厌它。 使用起来很糟糕而且速度很慢。 真丢脸。
Gallio looks like it's going to be awesome once it gets more stable (currently alpha).
It's not just a test framework, but a test automation platform, so it will work with many existing test frameworks (MbUnit, NUnit, xUnit.net) yet be fully extensible, with a number of built-in additional features such as report generation in many formats and code analysis tools.
I've also heard that it will be able to
Edit: It is indeed out of alpha now. We've tried it at our company and we really hated it. It was horrible to use and very slow. What a shame.
我已经使用 Nunit 有一段时间了,但我碰巧更喜欢 VS 中的东西。 所以,我现在使用 MSUnit。 只是希望在 VS 中安装较少的加载项。
I've used Nunit for quite some time, but I happen to prefer things baked into VS. So, I'm now using MSUnit. Just a preference for having less add-ins installed in VS.
NUnit。 我们可以在CC上使用它。
NUnit. We can use it on CC.
我喜欢 xUnit,因为它使用构造函数和 Dispose 方法,而不必将属性应用于其他方法来进行初始化等。
I like xUnit because of the way it uses the constructor and Dispose methods instead of having to apply attributes to other methods for initialization and all that.
MbUnit 与 NUnit 具有兼容的语法,但具有更多功能(尤其是数据驱动测试)。
MbUnit has compatible syntax with NUnit but has more features (especially data driven tests).
Resharper 对 NUnit 测试的支持非常棒,为我放弃 NUnit 设置了很高的标准。 我可以直接从 Visual Studio 运行解决方案中的所有测试,也可以深入研究并专注于特定测试。 当我的代码签入时,我的持续集成构建会运行相同的测试。 这让我对自己的开发过程充满信心。
The support for NUnit tests in Resharper is great and sets the bar very high for me moving away from NUnit. I can run all the tests in a solution directly from Visual Studio, or I can drill down and concentrate on specific tests. When my code is checked in, my continuous integration build runs the same tests. This gives me a lot of confidence in my development process.
MSTest
http://en.wikipedia.org/wiki/MSTest
我不知道是否它是我最喜欢的(还没有真正尝试过其他很多),但它很方便,因为它内置于 Visual Studio 中。
MSTest
http://en.wikipedia.org/wiki/MSTest
I don't know if it's my favorite (haven't really tried many others), but it's convenient since it's built into Visual Studio.
我以前使用 NUnit,但现在我更喜欢 Visual Studio 2008 附带的框架,只是因为它具有更紧密的集成并且更容易设置来测试私有方法。
我们在保持 NUnit 版本与团队其他成员同步方面也遇到了问题。 这是一个小烦恼(去升级,或修复项目引用),但随着切换它就消失了。
I used to use NUnit, but now I prefer the framework that comes with Visual Studio 2008, simply because it has tighter integration and is easier to set up to test private methods.
We also had problems with keeping the versions of NUnit synchronized with the rest of the team. It was a minor annoyance (go and upgrade, or fix the project references), but it went away with the switch.
我已经使用 NUnit 大约 4 年了,肯定会推荐使用它。 Reshaper - JetBrains 的 VisualStudio 插件,包括一个 UnitTestRunner,它与 VisualStudio 很好地集成,让您直接从 IDE 运行/调试测试。 Resharper、NUnit 和 RhinoMocks 是我首选的单元测试工具套件。
I've been using NUnit for some 4 years now, would definitely recommend using it. Reshaper - a plugin for VisualStudio by JetBrains includes a UnitTestRunner which integrates nicely with VisualStudio and lets you run / debug your tests from directly from the IDE. Resharper, NUnit and RhinoMocks is my preferred suite of tools for UnitTesting.
我使用过 NUnit 和 MS Test。 我喜欢 MS Test 与 IDE 的集成以及代码覆盖率的额外好处。 但由于性能原因以及流畅的断言等因素,我更喜欢使用 NUnit 而不是 MS 测试。
您可以使用名为 Should 的库编写与框架无关的断言。 它还具有非常好的流畅语法,如果您喜欢流畅的界面,可以使用它。 我有一篇与此相关的博客文章。
http://nileshgule.blogspot.com/2010 /11/use-should-assertion-library-to-write.html
如果我们使用 Should 之类的东西来进行断言,那么两个版本的测试几乎是相同的,我看不出两个框架之间有多大区别。
我在我的一个 博客。
I have used both NUnit as well as MS Test. I like the integration of MS Test with the IDE and additional benefit of code coverage as well. But due to the performance reason as well as things like fluent assertions I prefer to use NUnit over MS test.
You can write framework agnostic asserts using a library called Should. It also has a very nice fluent syntax which can be used if you like fluent interfaces. I had a blog post related to the same.
http://nileshgule.blogspot.com/2010/11/use-should-assertion-library-to-write.html
If we use something like Should for assertions then both versions of test almost lokks the same and I don't see much difference between the two frameworks.
I had done a comparison of NUnit and MSTest unit testing frameworks in one of my blog.