One of the limitations of Salesforce unit tests is that they do not make web service call-outs. So, how do you satisfy unit testing requirements for any apex code that does web service call-outs? You have two options.
Option 1: Programmatically generate a mock call-out
In the following example, a class which implements HttpCalloutMock is used to create a fake response:
Test.setMock(HttpCalloutMock.class, new HttpCalloutMockImpl());
Option 2: Use a static resource to upload a fake response
In the next example, an XML file named mockResponse was created and uploaded to Salesforce as a static resource. The following code could be used in your unit test to load the XML file and create a mock response:
In a previous post, I included notes from the premier training about Unit Testing. I recently viewed Podcasts of the Spring 2013 class, Apex programming on the Force.com platform and took some additional notes about testing. This post is a portion of those notes.