10 Apr 2009, 8:38 p.m.

Unit Testing Code which Consumes SOAP Services

One of the trickiest aspects of unit testing or Test Driving an application's code is testing those parts of the system which depend on an external system, such as a database or a SOAP service.

In this post I'll outline an approach to testing a class which happens to communicate with a third-party SOAP service using PHP's built-in SoapClient class. Hopefully, the principles involved will be applicable to the more general case of testing code which relies on an external system.

Posted by Simon Read more »
8 May 2007, 10:37 p.m.


Just a quick post to mention that, yes, my commitment to TDD show no signs of abating, especially in the face of the various unfamiliar technologies with which I've been working recently.

Today I came across JsUnit. Which may be old news to many, but I don't stray into JavaScript territory very often, and when I do, I'm usually quite frightened!

And how do developers reduce fear? Yup, we write some tests.

JsUnit has a nice UI, has maybe a 5 minute install/learning curve for anyone familiar with xUnits and just works. The only downsides I've found so far are that i) it doesn't work with my adored Opera and ii) some of the debugging messages are written in the sort of cryptic, broken English that suggests that the contributions of a native speaker might be welcome here.

Anyway, long story short, it's nice to know that even in the dark, dark world of client-side scripting, the gospel is spreading.

Posted by Simon Read more »
21 Jun 2005, 1 a.m.

Test-infected? Kind of

I've been spending increasing amounts of time recently getting to grips with Unit Testing and the Test-Driven "way". It can be hugely satisfying, but more often than not I'm finding it painfully frustrating. Don't get me wrong, I know it's the right way to go about things, I don't need any convincing. I did some growing up in public thanks to the lovely Advanced-PHP folks at Sitepoint, but I'm not there yet.

The best fully Test-Driven code I've managed so far is PHPTuring, and I'm trying to rewrite Briolette using TDD, but it's slow going. (If anyone of any talent is interested in helping develop a TDD MVC framework in PHP5, I'd be interested to hear from you).

Still, you can't beat that glow you get when you tame a nasty old piece of code with a couple of Unit Tests. Today with the help of Marcus Baker's excellent SimpleTest we did exactly that, and replaced about 40 lines of mission-critical cruft with a single regex. The confidence to do that simply wouldn't have been there were it not for the Tests.

Posted by Simon Read more »