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

查看:397
本文介绍了VS 2013 MSTest与nUnit与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 已正确集成到此设置中,并为我们提供了最简洁的界面.与我们应考虑的 MSTest 相比, NUnit xUnit 有明显的优势吗?

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与nUnit与xUnit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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