Testing CiviCRM

Published
2011-05-31 17:57
Written by
brylie - member of the CiviCRM community - view blog guidelines

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! 

Garden GnomeMost 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.

test coverageGnomes 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.

Further reading:

Filed under

Comments

Drawn-out metaphors don't get much better than that!

The gnomes are very useful and are able to mostly work, but we still need to have more real people willing to plant more of them on uncovered places and dark corners.

 

And of course also to help the gnomes that have turned red regain their nice green color.

 

There is a forum about testing, we encourage you to stop by and discuss how we can hoard our green gnomes gang.

 

http://forum.civicrm.org/index.php/board,49.0.html