views:

513

answers:

3

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

+6  A: 

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.

Scott Weinstein
Thanks for the links. Very helpful!
Kevin Babcock
+2  A: 

I've worked with a few unit testing frameworks for .NET and haven't found any of them to be dramatically different than another for my purposes.

Originally an argument against using the unit testing included with Visual Studio Team System was that people using the lesser version of Visual Studio could not run your tests. That's less of a problem now as I believe VS Pro now includes unit testing. I liked that Visual Studio could generate a lot of the test harnesses for you automatically.

As long as you're actually writing the unit tests, I don't think it much matters which tool you choose.

Paul Lefebvre
+5  A: 

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.

Brian Rasmussen
But why would you want to code without ReSharper? :)
TrueWill
Actually I am using Resharper and it is an excellent tool, but it doesn't change the fact that it adds to the cost and the complexity of the setup.
Brian Rasmussen