July 28, 2003

Unit Testing

Stray's shared php libraries for indymedia sites got messed up again. This means that indymedia argentina, chile, colombia, houston, palestine, peru, and uruguay are offline. This sucks but the world isn't going to come crashing down. Indymedia has build a network of high traffic websites on the rock solid principle that our servers crash. SF-Active the code behind those sites uses shared libraries written in PHP. The problem is that the libraries aren't exactly libraries, more like shared code and they don't have a fixed API. This means that as folks code along to add features they change the way the shared code works in small ways. It appears something along these lines happened last night. One solution would be to fix the API and do very strict versioning. But being radicals, we're all partial to extreme programming and UML based design specs don't seem natural. I think at least the shared code should be either thought of as libraries, with versions and the ability of each site to declare what version it uses, or each site on a single server should have it's own copy of the libraries. All of this leads me to my real point, Unit Testing.

Unit Testing
The idea is simple. Every piece of your code has a companion test. This test is written before the code, or retrofitted, but it lets you know that each functional unit of your code works. When you make changes, rearrange your code, objects, functions, or API, and the like you can run all the tests. It's not testing everything, because there can be bugs in the tests or conditions where the problem only occurs when a whole series of actions are taken.

So i started searching for Unit Testing systems for PHP. Turns out there are a fair number of decently documented systems. Unfortunately they all have the same name, PHPUnit. I'm including the links here for any php programmers who want to start doing things right and using unit testing.


My primary language is Perl, and for Perl there is basically two compatible choices, Test::Simple and Test::More which are pulled together in to a larger framework with Test::Harness. It all works very nicely, except when you've got complex objects it can be a bit of a pain to construct them just for testings. All in all I find i have a bit of trouble keeping myself to strict testing because i want to get to the code.

Posted by rabble at July 28, 2003 12:25 PM | TrackBack
Comments

Minor quibble, but my testing framework is not actually called PHPUnit (simply because everyone else's was).

Also as for testing complex arrangements have a look at mock objects. Makes life a lot easier, although the Perl one is very crude and you have to drag results out of it rather than setting expectations.

yours, Marcus

Posted by: Marcus Baker at August 5, 2003 12:30 AM

Please visit some relevant pages in the field of...

Posted by: at November 30, 2004 11:21 PM

free allmost nude teens beach teen tgp webcam teen images

Posted by: young xxx black teens at March 18, 2005 06:26 PM
Post a comment









Remember personal info?