In the programming world, Unit Testing is considered a religious issue that has many takers. Some vigorously for it, and some vehemently against it too.

A StackOverFlow query was answered in good spirit and (put pretty well !) and the explanation goes thus:

“Unit testing is a lot like going to the gym. You know it is good for you, all the arguments make sense, so you start working out. There’s an initial rush, which is great, but after a few days you start to wonder if it is worth the trouble.”

Just like the popular JUnit framework (for Java), the PHP world has PHPUnit (thanks to Sebastian Bergmann), a popular Unit Testing framework, that is not just feature-rich but quite extensible too.

Supporting custom configurations, PHPUnit is extensively used for the seldom used open-source applications, but more notably, its the first choice for quite a few well established frameworks (read Symfony) that command respect and a large fan-following. Further, its supported by some pretty big names for e.g. Zend (the basic engine behind PHP) or Ubuntu for that matter (which is the de-facto Linux distribution for a few years in a row).

For those living on the edge, exotic combinations of testing frameworks have allowed people to bring relatively niche concepts like Continuous Integration to PHP using free tools like Hudson (a.k.a Jenkins) and Phing. Integrating popular Revision Control systems (GitHub / FogBugz) as well as GUI testing frameworks (for e.g. Selenium), PHPUnit’s maturity speaks for itself.

The Invoicera team, already have in place such a test framework, and re-aligning more and more modules to this framework is an on-going process. As it stands, currently all API modules conform to a rigorous set of tests that are run periodically. Any change-set that is to be committed to the repository, is first tested and committed only when all tests pass.

Despite this, we do obviously get feedback that bring to the testing team’s notice, test-cases that got away. For all such issues, while the support-team responds to the support-query (after interacting with the technical-team), the testing-team in parallel, ensures that there are appropriate test-cases ready to avoid this specific issue in the future.

Finally, PHPUnit (or Unit-Testing in general) is a great way to reduce bugs. Although there obviously are classes of errors that this form of testing can’t catch, sensibly used, this is still a decent arsenal in a developers kitty to stop getting awful bug-reports from QA 🙂