Unit Testing Functions that Access Web-Services

Sorry about the title but I couldn't come up with anything shorter to describe the topic.

Background

The system we built for our client makes use of an external 3rd party web-service for certain data. Naturally there are a number of things that can happen which we need to handle gracefully.

  1. Web service not reachable
  2. XML returned not well formed
  3. Data doesn't conform to business rules (e.g. old data, incorrect datatypes etc)

Unit Testing

So how do we make sure that our code handles the above cases gracefully and correctly? We don't have the ability to influence the web service nor are we able to ask the provider to force the above cases just so we can test our code.

[More]

Unit Testing with OnMissingMethod()

I read a really great article yesterday written by Brian Kotek on using the onMissingMethod() in Coldfusion 8 to create mock objects to help with unit testing.

[More]