Unit Testing Your .NET code with NUnit
I've always believed in the value of testing my code. My problem has been that I just didn't like it. Given the option of either testing my code or monitoring the growth rate of the grass on my front lawnI'd take grass-watching every time. That was until I discovered xUnit testing. Now The Matrix is as dull as Grandma's place on a Sunday afternoon. The Joy of Testing has taken me over.
XP turns testing on its head and has developers writing tests before they write any code. The testing approach adopted by XP is very simple: Write a few tests for each new class or component and then write just enough code to pass the test. After the test passes, go back to your component and continue to add code. Each class will have a number of tests that ensure complete coverage. Integrating tests within the development cycle is made possible by the use of a simple testing framework called xUnit.
Kent Beck (of XP fame) invented the first testing tool of this type, called SUnit, for SmallTalk development. Over the last few years, the idea has caught on as developers have ported the idea to Java, VB, SQL, .NET, and about 40 other languages. Whatever language you're currently working with probably already has a xUnit framework ready for you to use. The Open Source project Web site, SourceForge, is a good place to look for these testing tools; and the Java Unit testing site (http://www.junit.org) has a long list.
Those of us who spend most of our time in the .NET world have not been left out in the coldNUnit is a .NET-based testing framework.
NUnit is not a complicated IDE add-in or a "let-me-invade-your-PC" kind of tool. You will see that writing tests with NUnit is really writing code. Keep telling yourself that as you start your new life of testing: I'm coding, I'm coding...