Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between the .NET Unit Testing framework out there?

I've heard many different opinions as to what makes one better than another. But can anyone provide a technical explanation as to why I should choose one unit testing framework over another. For example, I use Visual Studio Team System. Why would I choose an Open Source testing framework (NUnit, xUnit, MbUnit, etc) over Visual Studio's built-in unit testing capabilities? Does it matter?

Edit: To be clear, I'm not looking for an opinion on "Which unit testing framework is best"...I'm looking for technical details as to how they are different,.

like image 641
Kevin Babcock Avatar asked Dec 09 '22 21:12

Kevin Babcock


2 Answers

There's a comparison of the attribute and assertion differences between NUnit, MbUnit, MSTest, and xUnit.net at http://www.codeplex.com/xunit/Wiki/View.aspx?title=Comparisons

as for MSTest vs OpenSource solution, it's widely seen that the open source packages, in particular MBUnit and xUnit.net are where the innovation around unit testing is occuring.

That said, now that Peli de Halleux is working for MS and producing inovation like Pex things could change.

like image 71
Scott Weinstein Avatar answered Jan 14 '23 13:01

Scott Weinstein


I've only worked with NUnit and Microsoft's version of the same. In my opinion they are more similar than they are different. However, depending on you project setup there are a number of financial consideration which may be relevant.

Microsoft's testing framework is not available in their less expensive/free SKUs, but once you have paid for the entire package (which is not inexpensive, I know) you do get unit test, a test runner and code coverage in a single package, which is very convenient.

If you switch to NUnit you either have to give up VS integration or get a test runner such at TestDriven.NET or Resharper. When I looked at these they both required licenses for commercial use. I.e. the cost per developer is increased. Additionally these tools do not have code coverage, so you have to get something like NCover. Again, this carried a license for commercial usage, when I checked.

Admittedly it has been a while since I looked into this so the licensing may have changed, but the extra cost per developer was part of the reason we opted to go with the Microsoft solution. It may be the case that VS Express plus the other tools are less expensive than VS Team Foundation, but since we had to go with VS TF anyway that did us little good.

If you're doing open source / non commercial projects I believe you may be able to get free versions.

like image 41
Brian Rasmussen Avatar answered Jan 14 '23 14:01

Brian Rasmussen