14 August 2007 · About 1 minute read

Discovering Unit Testing

Testing is unquestionably the most important aspect of software development, and with every iteration of a project, the testing required becomes exponentially greater.

I have been looking into unit testing as a means of providing automated, scripted testing, for a number of my larger projects, after finding myself breaking things far more often than fixing them. Testing (and test-driven development, that is, the formulation of tests and expectations before any code solution is written) is part of a healthy agile development practice:

When you create your tests first, before the code, you will find it much easier and faster to create your code. The combined time it takes to create a unit test and create some code to make it pass is about the same as just coding it up straight away.

Extreme Programming; Code the Unit Test First (www.extremeprogramming.org)

Why had I not looked into this before? Clearly, anyone would be crazy not to invest the (relatively short) time into test driven development of projects. I am currently using symfony and Cocoa for my projects, as well as starting to wrap my head around ruby on rails. All three frameworks are capable of tightly integrating with unit testing frameworks, whilst symfony and rails (I believe) also employ functional and interface tests.

A comprehensive test environment gives the confidence to deploy applications to production without fear of breaking something important, as well as ensuring a clear set of requirements. I am now reconfiguring all of my major projects around a test-driven design methodology. Symfony uses the built-in Lime testing framework which, once you get around the intricacies of configuring for database access, works very well.