views:

2187

answers:

10

I'm looking to introduce a unit testing framework into the mix at my job. We're using Visual Studio 2005 (though we may be moving to 2008 within the next 6 months) and work primarily in C#. If the framework has some kind of IDE integration that would be best, but I'm open to frameworks that don't have integration but are still relatively simple to get set up. I'm going to get resistance to it one way or another, so if I can make sure what I'm pushing isn't a pain in the neck, that would help my case.

The obvious choice from the research I've done so far points to nUnit, but I'd like to get the impressions of someone who's actually used it before recommending it to my team.

Has anyone out there used nUnit? If so, are there any pitfalls or limitations of which I should be aware? Are there other good options out there? If so, if you've used both nUnit at that, I'd greatly appreciate an idea of the strengths and weaknesses of them.

Eric Sipple

+8  A: 

Scott Hanselman had a good Podcast about this, entitled "The Past, Present and Future of .NET Unit Testing Frameworks":

Hanselminutes #112

Michael Stum
That is was a money podcast. It highlights all the major unit test frameworks. I personally started using xUnit because of what I heard on this pod cast.
Chuck Conway
+27  A: 

I think NUnit is your best bet. With TestDriven.NET, you get great integration within VS.NET. (Resharper also has a unit test runner if you're using it). NUnit it simple to use and follows an established paradigm. You'll also find plenty of projects/tutorials/guides using it which always helps.

Your other main choice is probably MBUnit, which is more and more position itself as the BDD framework of choice (in conjunction with Gallio http://www.gallio.org).

Karl Seguin
+3  A: 

Visual Studio 2008 has a built in test project type that works in a similar way to NUnit, but obviously has much tighter integration with Visual Studio (can run on every build and shows the results in a similar way to the conversion results page when upgrading solution files), but it is obviously not as mature as NUnit as it's pretty new and I'm not sure about how it handles mocking.

But it would be worth looking into when your team moves to VS2008

denny
+1  A: 

mbUnit is worth alook, it has a set of features comparable to NUnit, it has its own GUI, or can be integrated into VS if you have Resharper. I would also recommend Rhino Mocks if you are doing any sort of TDD.

Dan
+1  A: 

I would say mbUnit also, I like being able to run a single test many times just by specifying inputs and result right above the test function. Horrible description of what I mean so here is a link that shows you what I mean.

Kevin Sheffield
+2  A: 

When I started unit testing I started with NUnit as it is simple to set up and use, currently I am using the built in test runner that comes with Resharper, that way I can easily flip between code and test results. Incidently NUnit detects when you have compiled your code so you do not need to do any refresh in NUnit. Resharper automatically does a build when you choose to run a specific test.

capgpilk
+4  A: 

The built in unit testing in VS 2008 is alright, but its difficult to integrate with CruiseControl.net, certainly a lot harder than normal NUnit.

So go with NUnit if you plan to have nice automated tests.

qui
+3  A: 

We've been using xUnit.net. It seems to combine all the best of nUnit, mbUnit and MSTest.

I majorly regret the wasted time not having tried it before I switched.
Ruben Bartelink
A: 

A very interesting post on using Typemock and Nunit.

+2  A: 

Try also PEX tool It Microsoft's own probably soon to be integrated into VSTS and does support NUnit , MbUnit and xUnit.net

I use also small Console Application for testing one class or small library. You could copy paste the code from here

YordanGeorgiev