I’m in love! No this isn’t an unlikely new blip on my social radar. It’s my recent introduction to NUnit for C# and an accompanying book by Andrew Hunt & David Thomas called "Pragmatic Unit Testing".
The introduction came on the project I’ve been on for the past few months – a commercial web content management system called "Symphony". Specifically, I’m currently writing business logic for the messaging subsystem. Unlike web content, business logic is arguably more difficult to test because the output from the code has to be solicited by a calling application before one can determine if anything they’ve written works as expected. And it’s here where the role of "unit testing" becomes relevant.
The author points out that a lot of developpers get anxious about testing. However, I genuinely found it very
useful to work with testers because they’re helping me create a more solid application – not just trying to break your wonderful code in a mean-spirited way. Developpers are all human beings (well most of us are anyway) and as such mistakes are inevitable. Recognizing that, one see’s testers and test processes and being an asset to the process of creating solid applications everyone will rely on.
Admittedly, this is the very first time I’ve been part of a formal testing process. I’ve had my code tested on numerous prior occasions, of course – but this is wehre I’m finally "getting my wings" on the whole deal and NUnit is definitely a tool that makes that process easier. Particularly given this is raw code being written on the business layer of the application with no interface logic (at this phase). Without testing, dozens or (more likely) hundreds of undiscovered bugs would be released into the applciation alpha that would painstakingly have to be first discovered, then debugged using cycles that could take far, far longer. Even more incredible is that the companion testing software for C# is available at http://www.nunit.org
– free as an Open Source package!
So there’s no excuse. NUnit’s GUI facilitates the process of creating and executing test cases in tandem with Visual Studio. A "stoplight’ metaphor (red, yellow and green LED-like indicators) give you a solution-wide view of what’s working and what’s not. And textareas adjascent provide exception, stack-trace and object state data to fill in the details. The quality that has for so long eluded web developers and their applications is now practical and available to projects leveraging .NET and C# in particular (because of the volume of documentation for it – but NUnit works with C# and VB.NET quite readily). And NUnit certainly seems like a solid tool for testing any enterprise application; if you can get through the usual stigma associated with testing practices. But even a modest trial run with NUnit ought to get even the most stone-faced cynnic sold.