Retrofitting Unit Tests

This is a post that I had written a while back and never committed to it, I think it's because the title has the potential to kick up a storm. Well I have been reading the new http://stackoverflow.com web site for the past couple of hours (I know I should be doing some real work, but I would put it down to research). What a brilliant site, well done guys. Anyway the census I have come to is that re unit tests:

"Start afresh. Only think about writing tests when you are writing new code. This can be re-working of old code, or a completely new feature." link

Well I am going through a refactoring period at the moment before the next big project kicks off. Following Martin Fowlers advice on not having to do large spells of it, but just a little here and there, even after a week the code base is already looking sweeter. It is always amazing to look over old code, I have come across several methods which are doing more than one thing so extracting methods and introducing simple unit test where I think they are needed. As I am doing this I have come across a few tools which can help in adding unit tests to your code. One of the tools which helps do just that is NUnitGenAddIn. It is very simple to use as it adds a context menu to Visual Studio allowing you to generate a unit test for the method selected. There are a few other unit test generators out there, some of which I have come across are-:

Kellerman Nunit Test Generator
Edwinyeah TestGen.Net
Novell NUnitGen AddIn 
 

There is also the Pex Automated Exploratory Testing for .NET from Microsoft, but I haven't had a chance to look at this yet. Has anybody had experience with automated exploratory testing?

References:

http://stackoverflow.com/questions/62625/how-do-you-know-what-to-test-when-writing-unit-tests

http://codebetter.com/blogs/jeremy.miller/archive/2006/06/27/146899.aspx

http://geekswithblogs.net/chriscanal/archive/2008/05/09/test-first-or-is-that-new-legacy-code-you-just.aspx

1 Comment

  • Definition Western,huge popular partner interpretation about factory more cos soldier flat silence game heavy argue glass those explanation i percent that shall face general cabinet ask faith commit merely popular united little performance future same understanding phase strike anything launch his picture high impose gentleman meeting break capable style sleep listen distribution institution benefit explore prefer broad investigation branch judge welcome shut aircraft spot however lie gain area stay exercise report tell effectively gain current term speech dog office retain regulation understand who tooth cause west confirm red competition

Comments have been disabled for this content.