Imagine for a moment that CiviCRM is a garden. In all its object oriented complexity lie bugs and weeds that need to be effectively discovered and managed. Managing a garden the size of CiviCRM is a daunting task for one individual, and even a team of developers along with a community of end-users and testers still need help. There is indeed help to be found!
Most gardens have a gnome or two. CiviCRM has dozens. Our little army of workers were deployed from the xUnit, a top secret, multi-lingual consortium who's primary concerns are the sanity of software developers and confidence of end-users. These assertive xUnit workers diligently patrol the garden for problems. When a problem is found, the local worker will switch xe's hat from green to red in order that developers may find the exact weed or bug and *nix it. This allows developers to keep on innovating with the comfort that they will know exactly when and where problems arise in the garden, ahem, source code.
Gnomes aren't the only active agents in a garden. When a garden is being prepared at the beginning of the season, it is common for a gardener to replenish the soil by adding amendments. Amendments must be thoroughly mixed into the soil in order to be effective. Likewise, unit tests must be spread throughout the source code.
There are typically several different amendments spread throughout a garden, each amendment complementing the others. Developers create web tests to complement unit tests. Web tests simulate a user's interaction with the site and exercise many aspects of the code base at once. Combining web and unit tests creates a holistic, or system wide, testing regiment.
While testing seems stressful at times, the peace of mind that comes with a solid and stable project more than makes up for the time spent writing tests. Developers can continue to evolve the software knowing that they will be quickly informed if their activity causes any unexpected errors. Clients can safely invest time and money in the software knowing that they are receiving value and stability in return.
At the recent CiviCRM Code and Test Spring (May 2011) we had some knowledge sharing sessions regarding CiviCRM test coverage and methodology. I had the pleasure to work and learn with Dave Greenberg and Stacy Liou. Dave gave me a crash course in testing, using Selenium and PHPUnit to build and automate tests. Stacy demonstrated her GNU/Linux shell skills while working through some red & green tests with me.