views:

469

answers:

5

Can somebody recommend a good (free) generator for NUnit Tests?

+5  A: 

You're going to have to say exactly what you want the generator to do. Personally I've always found automated generators to be more hassle than they're worth - my fingers work just as well :)

On the other hand, you might want to look at Pex which works in conjunction with Code Contracts to explore your code and generate tests in an intelligent way. Pex is able to generate tests in different flavours, including NUnit.

Jon Skeet
+1 for the fingers doing the work.
Chris Missal
NUnit support is now out of the box for Pex.
Peli
@Peli - excellent. Will edit.
Jon Skeet
+1  A: 

Test generators are good at giving you high code coverage. Unfortunately high code coverage doesn't always mean good tests have been generated. I tend to write them out by hand myself.

AutomatedTester
A: 

Pex is free for Academic use, however it is currently still Beta quality and may be a lot more than what you are asking for. Nunit Test Generator isn't free, but at $9.95 it almost may be, however it doesn't do that much more than setting up the testbed and creating a test for every public method.

Kris Erickson
+1  A: 

Dont do it. Tests with value are generated first, by a human (ideally a pair thereof) with their thinking caps on, not their brain in neutral. (That is if you're referring to generating a test per method, or anything else that's not based on some deep insight a la Pex as Jon Skeet said)

Ruben Bartelink
A: 

Just downloaded and installed Novel's NUnitGenAddIn. It's kind of old-ish (seems to have been last updated in 2006), but once I tweaked the NUnitGenAddIn.AddIn file (change the Assembly path and update the Visual Studio version number to 9.0), it does exactly what I wanted: right-click generation of reasonable unit-test stubs from within Visual Studio 2008. Dunno if that works for what you want, but definitely free (GNU Lesser GPL).

Ogre Psalm33