I'm new to TDD, and am looking at options for unit testing my Visual Studio 2010 solution. This solution is an MVC3 web app, which I'm attempting to use DDD with IoC, repository, and unit of work patterns. It also uses EF4 & the EF4 POCO templates. (I tried to model much of it from the Microsoft N-layer App, also borrowing design patterns from a couple other blogs).
I've been searching and reading about this for a couple of hours, and it seems I'm finding conflicting information everywhere I turn. Much of this is due to old results coming up, and evolving options for Visual Studio 2010.
I know there are several options, but again, I'm having a hard time discerning outdated options from the newer options, and there is some ambiguity in the references people use. Even the popular discussion here has some old/ambiguious/conflicting information.
For example:
Is there a difference between MSTest, Visual Studio Unit Testing Framework, and Microsoft.VisualStudio.TestTools.UnitTesting
? If so, what? It seems these are different, but have been improperly referenced in some discussions I've seen.
Since the author of NUnit also authored xUnit, does that mean xUnit replaces NUnit, thus rendering NUnit deprecated? It seems that some, even today, prefer NUnit. But if NUnit is deprecated, why would one start today using NUnit over xUnit? If NUnit is not deprecated, does this mean xUnit isn't taking off like it was originally intended? Why would the author continue to support two seemingly redundant tools?
Which of these integrates into VS2010 without having to resort to separately executing command lines to test, or having to purchase tools like TestDriven.Net? (I do have ReSharper, though, if this supports any of these.)
Have there been any notable changes recently to any of these that would make older discussions of these invalid?
Are there any others I should consider over or in addition to the ones I've mention above ?
I'm not necessarily looking for an in-depth comparison (though you're more than welcome to provide one if you'd like), but more of an up-to-date consensus of the current tools that are being used today for new VS2010 development.
On the surface, the "Visual Studio Unit Testing Framework" seems to integrate nicely into VS2010 (Pro) out of the box, and seems to be easy to get up and running quickly, as opposed to some of the others, even if it is a bit bloated. But since I'm new, I don't want to get into it 3 months down the road, then realize I've painted myself into a corner just because it seemed easier to pick up.
I also know that this question may be considered a "bad" question by some, due to it's open and broad nature, but while these are different questions, I feel they're all related, and all stem from my general confusion over the ambiguous and conflicting points I'm finding about unit testing in VS2010.
Thanks in advance.
EDIT: This is meant to be more of an updated discussion of the nearly three-year-old popular discussion I linked to above. That discussion has some good points, but a lot of things (could) have changed in three years, and I like a more current evaluation of the subject.
- All the same.. just confusopoly (MSTest is the runner, framework is the DLL). I'll refer to it as MSTest from now on.
- Don't have much mileage with xUnit. I lie firmly in the NUnit camp. Not sure of the history.. but AFAIR Jim Newkirk was even hired by Microsoft for MSTest development. I can definitely answer that NUnit isn't deprecated (or even slowing down). I just got a bug fixed within days of reporting it. Charlie Poole has been heading it for a while (and doing a stellar job). NUnit is the oldest (and based on the xUnit family of test runners that started with Beck's SUnit and JUnit). I've grown up with it (so to speak). It just stays out of the way and has almost all the features you need for day to day development. MSTest offers VisualStudio integration but muddies the waters with tiny subtle deviations that trip me up (parallelization, fixture setup must be static, etc.etc.). The others try to extend the test runner in diff ways (change in terminology e.g. Theories over test-fixtures) and ways in which you write your tests. I've never had to extend my test-runner ; maybe I've not worked in those environments that need it.
- NUnit doesn't integrate off the shelf like MSTest. But if you have Resharper (which you should), it plugs this gap. Also MSTest AFAIK requires a copy of the whole IDE (of a particular edition) unlike NUnit which can be just copied onto a folder and run. Sort of leads you into TFS with "free code coverage if you use MSTest". If your org uses TFS for CI, you will find integrating anything other than MSTest to be "more custom code that I need to write".
4 and 5 things keep changing so difficult to form a final answer.
Summary: NUnit is simpler to learn (will take you a day or less) and most of the literature w.r.t. TDD will go down easier if you know it. I personally never had a reason to move (e.g. NUnit doesn't do this that xUnit does and I cannot live without this). Unless you're big on MS-CI (and "free" Coverage and TestImpact), I'd say start with NUnit and work your way up. No silver test-runner.
The tool doesn't guarantee success, it's how you use those tools. Pick one, get started and adapt.
HTH
This is not a life-altering decision. I use MSTest in some projects, NUnit in others. I've never tried xUnit, but I'm sure it's fine too.
For myself, I prefer MSTest simply b/c of the built-in templates and keybindings that make testing quick to run and setup. That said, if anyone on the dev team can't use VS, it's no joy.
When using NUnit, I didn't want to pay for Resharper (sorry, I've seen it in action but simply haven't seen the light on it, I guess). I use Visual NUnit instead. http://visualstudiogallery.msdn.microsoft.com/c8164c71-0836-4471-80ce-633383031099 It's free, integrates w/ Visual Studio's UI (albeit it's not a beautiful UI, but it's better imo than TestDriven.NET).
ReSharper can run tests written in xUnit, NUnit, and MSTest.
xUnit needs a (free) plug in for ReSharper that is linked to from the xUnitContrib page: http://xunitcontrib.codeplex.com/
NUnit and MSTest both work out of the box.
In ReSharper you can see what unit test frameworks are installed under ReSharper -> Options -> Unit Testing (at the bottom under tools in the left hand pane)
I can answer #3: TestDriven integrates with VS2010 nicely.
You get a context menu option to run tests, and you can even hook some of the commands to shortcut keys, so you can run all your tests quickly.