I am trying to use the new HttpCalloutMock
following the guide here.
This is a new feature, and I was hoping to make some better test cases for using web-service callouts that respond with a SOAP Message.
However, after setting up the HttpCalloutMock
response, I've since discovered that the TestMethod
continues to throw: TypeException: Methods defined as TestMethod do not support Web service callouts, test skipped
I would assume this is being thrown from the imported on the WS Callout definition at WebServiceCallout.invoke()
, since this isn't a simple HTTPRequest
is it even going to be possible to test my web-service callouts?
@isTest
global class ApiListMtgListMeetingsResultTest implements HttpCalloutMock {
// Implement this interface method
global HTTPResponse respond(HTTPRequest req) {
system.debug('Mock ApiListMtgListMeetingsResult');
HttpResponse res = new HttpResponse();
res.setHeader('Content-Type', 'text/xml;charset=UTF-8');
res.setBody('<soap:Envelope>...</soap:Envelope>');
res.setStatusCode(200);
return res;
}
}
In the guide, setting the Test.Mock
seems to capture any HTTP callouts via HttpRequest.send()
, no explicit settings required.
Update
I guess I should clarify, I am trying to use HttpCalloutMock
to respond to a call from:
WebServiceCallout.invoke()
WebServiceCallout.invoke()