Saturday, 8 March 2008

Unit testing tools for PHP

One of the big themes at the moment seems to be unit testing and test-driven development. We've just had some training from iBuildings on PHPUnit, but the one we're really interested in using day-to-day is Simpletest. The reason we're leaning towards Simpletest is that PHPUnit is normally run from the command line, which seems a bit wrong-headed for something that's such an integral part of web development. It does have a few lines that you can add to make it execute when the test case is viewed in a browser, but the presentation of the results leaves a great deal to be desired. Simpletest runs when the page is viewed in the browser, and also has some other features which PHPUnit lacks presently. The only thing that seems to be better about PHPUnit is the fact that it plays nicely with XDebug, which can give you some useful statistics about test coverage.

1 comment:

Anonymous said...

Actually we use SimpleTest a lot at Ibuildings too; SimpleTest and PHPUnit are always one step ahead of eachother. SimpleTest was the first that featured mock objects, PHPUnit then got code coverage, etc.

The advantage of commandline support is that you can use it to run the tests automatically and have them email you only if something fails.