VS 2013 MSTest vs nUnit vs xUnit [英] VS 2013 MSTest vs nUnit vs xUnit

查看:24
本文介绍了VS 2013 MSTest vs nUnit vs xUnit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到关于这个主题有很多问题,但不知何故我还没有找到一个满足我需求的问题.

I realize there have been a LOT of questions on this topic but somehow I haven't found one that addressed my needs.

我的团队希望开始对我们的应用程序进行自动化单元测试.我们以前从未这样做过,团队中没有人对此有太多经验.我被要求研究并找到一个自动化单元测试的框架.到目前为止,我已将选择范围缩小到 MSTest、NUnit 和 xUnit.

My team is looking to start automated Unit testing our application. We have never done it before and nobody on the team has much experience with it. I have been asked to research and find a framework for automating our Unit Testing. So far, I have narrowed the choices down to MSTest, NUnit and xUnit.

在整个互联网上,我都阅读了关于 MSTest 的负面评论,但它似乎是我最方便的工具.

All across the internet, I read negative reviews about MSTest but it seems the most convenient tool to me for our purpose.

1) 我们的应用程序是 .NET

1) Our application is .NET

2) 我们在整个团队中使用许可的 VS IDE 进行开发.

2) We use licensed VS IDE for our development across the team.

3) 源代码控制是 Team Foundation Server 2010

3) Source Control is Team Foundation Server 2010

4) 我们计划将 CI/CD 集成为我们的软件交付流程的一部分.

4) We plan to integrate CI/CD as part of our software delivery process.

我觉得 MSTest 直接集成到此设置中,并为我们提供了最干净的界面供我们使用.NUnitxUnit 是否比 MSTest 有我们应该考虑的显着优势?

I feel that MSTest integrates right into this setup and provides the cleanest interface for us to work on. Is there a significant advantage with NUnit or xUnit over MSTest that we should consider?

推荐答案

我有偏见,因为我在 NUnit 上工作,但 NUnit 或 xUnit 的优势在于这两个框架都提供了更多功能,如数据驱动测试、并行执行和主机高级功能.

I am biased because I work on NUnit, but the advantage of NUnit or xUnit is that both frameworks offer more functionality like data driven tests, parallel execution and a host of advanced features.

也就是说,MSTest 没有任何问题,尤其是在您的团队对单元测试不是很有经验的情况下.它与 Visual Studio 和 TFS 完美集成,因此添加测试相当轻松.NUnit 和 xUnit 也集成得很好,但它们可能需要更多设置.

That said, there is nothing wrong with MSTest especially if your team is not very experienced with unit testing. It is well integrated with Visual Studio and with TFS, so adding tests is fairly painless. Both NUnit and xUnit integrate well too, but they may require more setup.

继续并从 MSTest 开始.这是单元测试的简单介绍.如果您开始遇到 MSTest 的一些限制,那么迁移到 NUnit 或 xUnit 是相当容易的.对于简单的情况,只需更改 NuGet 包,然后查找/替换属性即可.

Go ahead and start with MSTest. It is an easy introduction to unit testing. If you start running into some of the limitations of MSTest, then it is a fairly easy migration to NUnit or xUnit. For simple cases, it is just a matter of changing your NuGet packages and then find/replace the attributes.

在 xUnit 和 NUnit 之间进行选择时,两者都是不错的选择,但各自的理念不同.NUnit 往往更灵活,并允许一系列测试风格,并可用于集成测试.然而,它足够灵活,可以让您在脚下射击自己,并允许您编写纯粹主义者会皱眉头的测试.NUnit 让您自行选择.

When it comes to choosing between xUnit and NUnit, both are great choices but each has a different philosophy. NUnit tends to be more flexible and allows for a range of testing styles and can be used for integration tests. It is however flexible enough to allow you to shoot yourself in the foot and allows you to write tests that purists would frown upon. NUnit leaves the choice up to you.

然而,xUnit 往往更加固执己见,并通过单元测试将您推向成功的坑".根据我的经验,它非常适合新建项目,但如果不进行重构,它会使测试一些架构不佳的棕地项目变得困难.

xUnit however tends to be a bit more opinionated and pushes you towards the 'pit of success' with unit testing. In my experience, it is great for green field projects, but it can make testing some poorly architected brown-field projects difficult without refactoring.

最后,这些测试框架中的任何一个都不会出错.

In the end, you can't go wrong with any of these test frameworks.

这篇关于VS 2013 MSTest vs nUnit vs xUnit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆