Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [webservicemock]

The tag has no usage guidance.

9
votes
1answer
665 views

How do I unit test code that includes a callout?

This is a canonical question and answer developed by the community to help address common questions. If you've been directed here, or your question has been closed as a duplicate, please look through ...
0
votes
1answer
191 views

Response not received using MultiStaticResourceCalloutMock Class

I have below piece of code in an apex class that I am trying test. HttpResponse res = http.send(req); String responsejsonString = (String)JSON.deserialize(res.getBody(), String.class); List<...
1
vote
0answers
28 views

Test Webservice Callout [duplicate]

Can anyone see what I am doing wrong? I am not getting back any data from my mock callout. Below- jsonStr is what is returned from the webservice and it is being returned as null. Apex: public ...
1
vote
1answer
75 views

Webservice mock callout goes to the webservice original class and fails

I am using a WebService callout, returning a string, and testing it; I am quite new to it. The problem is in the Mock class. When I am debugging it, the response element is created, the string is ...
2
votes
0answers
2k views

Trailhead Data Integration Specialist Superbadge || Test Class is Failing

I wrote the below test classes - @isTest global class ProjectCalloutServiceMock implements HttpCalloutMock{ global HttpResponse respond(HttpRequest req){ System.Debug('--++-- Inside ...
1
vote
1answer
77 views

Testing Webservice Callouts : Methods defined as TestMethod do not support Web service callouts

The following class is wsdl2apex generated. Can anyone help me on how to write test class for the same //Generated by wsdl2apex public class e_services { public class EPort { public ...
6
votes
1answer
653 views

Issues Testing Webservice Callouts

I am trying to write a test class for a simple HTTP POST web service call. (I am just sending a three line json body to an endpoint). Where I having trouble is trying to test my apex code. I ...
0
votes
0answers
334 views

How to handle multi callout in test class?

I have webservice class which have multi callout.For the first callout i have some list of URl's.From the list of URL's I want to do the second callout and so on. apexCode: global with sharing class ...
0
votes
1answer
267 views

Multiple Webservice Test Mock

I have a method that calls multiple webservices in it. When I implement a mock webservice how does it tie that mock webservice to the actual web service it is mocking? Is it possible to create ...
0
votes
0answers
99 views

Help testing a web service callout for a trigger that doesn't directly request a callout

I'm attempting to include a mock web service callout in a test for a trigger, though the trigger and test don't explicitly execute a callout. I've found this documentation on creating the mock, but I'...
3
votes
1answer
814 views

Webservice callout - Test class - not working

I have batch class that makes a HTTP callout to a remote web service. To deploy into production, I have created a test class with StaticResourceCalloutMock. I am executing the test class in a full ...
4
votes
1answer
2k views

Callout Mock Responses & multiple HTTP Status Code values

I'm trying to unit test the behavior of some code which performs callouts and its logic is dependent on the HTTP status code of the response - 200 vs 401. The pattern being exercised is familiar: ...
4
votes
1answer
35 views

Security Scanner Results shows asserts needed for mock class.Is it mandatory?

We made a security scan through 'Force.com Security Scanner' which says that asserts are mandatory for mock class.But we have used asserts for all the test classes which makes use of those mocks.I ...
4
votes
1answer
1k views

Test class for a controller that has logic to query the external object records

We have enabled the Lightning connect and defined an External Data Source for Lightning Connect - Odata 2.0 Adapter and the External Object records are loaded from Informatica. The functionality ...
1
vote
1answer
220 views

System.LimitException occurs in WSDL Class

I'm getting System.LimitException: Too many callouts: 101 error message in my WSDL class file generated by SFDC. Repeated error was shown as following: Class.ServiceHistory_wsdl....
0
votes
1answer
139 views

Custom Apex soap API

We have written a custom Apex soup API for integrating with ERP System. Our wsdl works fine .Currently we are accepting the records response one by one sent by ERP. Now my question is if ERP sends the ...
1
vote
1answer
707 views

Test class for Batch class with web service callout and test data

I have a batch class which in turn makes REST callouts(No future annotation). Now I want to write test class for same. Currently what i tried - -StaticResourceCalloutMock class in salesforce - ...
2
votes
0answers
79 views

Weird issue (NEW BUG) with Test.SetMock and body.toString() - Dreaded Uncommitted work pending

Using test.setMock between test.startTest and test.stopTest DML performs fine everywhere except: This code fails unless the insert is not done: sr = [Select Body From StaticResource Where Name = '...
3
votes
2answers
78 views

Loading data before Webservice callouts?

I need Opportunity record to be inserted in test class and then use that Id in webservice call out. Tried every different combination but it asks me commit the DML operation before doing webservice ...
20
votes
3answers
2k views

Mocking a webservice CalloutException for a SOAP Fault

I have a mock class for a web service that implements WebServiceMock. With some requests the actual web service being mocked will return a SOAP Fault that results in a System.CalloutException in Apex....
2
votes
1answer
433 views

Webservice calls in unit Tests

I could run unit test for webservice method call using mock very well, but when I call a webservice method and after that another webservice method in the same test, I get "You have uncommitted work ...
1
vote
2answers
457 views

Implementation of AWS Toolkit test classes. Test.setMock Have any done it?

Background We are integrating with AWS Services, so we installed the Amazon Toolkit and right after installed we run the Apex Test Execution and we find out that there are 6 test methods not passing ...
4
votes
1answer
715 views

Too many callouts 11 while testing using webservicemock interface

i have written a test class for a controller in which one of the method makes a callout. This is one single invocation of external SAP webservice. But my debug log shows more than 10 invocation of the ...
2
votes
2answers
204 views

Testing webservicemock never reached the response line in the generated class. why?

written a test class to test the callout that is using SOAP. I have generated class using WSDL. The response line in the generated class not covered though i tried several ways. Given below is the ...
15
votes
2answers
25k views

Method defined as testMethod do not support web service callouts, test skipped

I have been struggling with this error for a few days now. I get this error every time I try to run a test for a method that has an httpCallout. I followed the architecture from http://www.salesforce....
2
votes
0answers
38 views

why this simple example in this article throws error? [duplicate]

i have created all the classes in this link just to see how the Test mock working. http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex_testing.htm but i ended up in ...
3
votes
1answer
4k views

Help Testing a Web Service Callout

I have set-up an APEX class that uses a web service callout to create a PDF and attach it to a contact record. However, I can't push it into production because the web service callout is skipped in ...
3
votes
1answer
198 views

My test classes are contributing towards uncovered code

I have a test class containing several WebServiceMock implementors. He looks like this: @isTest private class MyTestClass { public class ValidateMock implements WebServiceMock { public ...