Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @isTest
- private class WebSvcCalloutTest {
- @isTest static void testEchoString() {
- // This causes a fake response to be generated
- Test.setMock(WebServiceMock.class, new WebServiceMockImpl());
- // Call the method that invokes a callout
- String output = WebSvcCallout.callEchoString('Hello World!');
- // Verify that a fake result is returned
- System.assertEquals('Mock response', output);
- }
- }
- @isTest
- global class WebServiceMockImpl implements WebServiceMock {
- global void doInvoke(
- Object stub,
- Object request,
- Map<String, Object> response,
- String endpoint,
- String soapAction,
- String requestName,
- String responseNS,
- String responseName,
- String responseType) {
- docSample.EchoStringResponse_element respElement =
- new docSample.EchoStringResponse_element();
- respElement.EchoStringResult = 'Mock response';
- response.put('response_x', respElement);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement