Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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.

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

1) Our application is .NET

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

3) Source Control is Team Foundation Server 2010

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

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?

like image 336
Nakul Shukla Avatar asked Jun 27 '16 21:06

Nakul Shukla


2 Answers

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.

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.

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.

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 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.

like image 164
Rob Prouse Avatar answered Oct 08 '22 06:10

Rob Prouse


I would like to add one negative aspect of XUnit. It does not have even a basic documentation, nothing beyond "Get Started". No API, nothing.

like image 20
newprint Avatar answered Oct 08 '22 04:10

newprint