Unit Testing Strategy – web2project

I’ve been quiet on web2project for the past few weeks, but I thought I should share some of the latest developments.

The single biggest improvement currently is the inclusion of Unit Testing.

Unit Testing has been on the agenda for months and years.  The problem was that something else – often bugs, sometimes new features – would creep up and push it off the todo list.  And then something happened at php|tek this time around:

I met Trevor Morse – lead developer of Azorus and the founder of the Nova Scotia PHP Developers Group.

Within their company, they took a very familiar approach.  They started writing unit tests for the new features and as bugs were discovered on existing features.  While it sounds like a slow, painful process, it actually works out quite well.  Instead of seeing tens or even hundreds of thousands of lines that need to be tested, you see only a given function or only a given bug.  Over time, this steadily improves the quality of the codebase and also sets a good example for current and future developers on the “right way” to do things.

So a few weeks ago when Trevor passed me some Unit Tests and a Phing script to run them, I was suitably impressed not only by his motivation, but also by his beginnings on this strategy.

Within a few days, I had integrated his phpUnit tests – available since r444 on 18 June – and expanded the Phing script to include some other functionality such as a php lint check, and a coding standards check (PEAR).  In the weeks since, he’s provided Unit Tests for the vast majority of the Companies Module and some of the Project Module.  In the meantime, I’ve been working on some of the supporting classes and functions used by the rest of the system as I’ve tracked down and closed a few bugs.

In addition to improving the quality of the system, Trevor has found and properly diagnosed at least two bugs while I’ve found a few others.  Combine with this the little performance improvements and tweaks that have been made and the next release could be even more perfomant.  If you’d like to browse the tests and offer feedback – constructive criticism only, please – feel free to browse our SVN repository on Sourceforge.

And in case you want to see them, the web2project Unit Test Report is available here… warts and all.

Warning: Since the vast majority of the tests run against the database with users of known permissions, etc, under no circumstances should you run the tests against your production system.

In other news, web2project v1.1 has been specified.  There are a number of cleanups, improvements, and fixes going in – 27 to be exact.  A couple are important, most are pretty small, but the bulk are necessary to the overall improvement of the system.  About six of them are already closed, a few more are on the way.