You need to sign in to do that
Don't have an account?

System.TypeException: Testmethods do not support webservice callouts
Hi,
While Running a testmethod, I am getting the exception "System.TypeException: Testmethods do not support webservice callouts". This testmethod is for testing a trigger, which is calling the Google API service for Latitude and Lonitude Conversion. I am using Salesforce API version 15.0
What can be the alternative way? Please help..
Thanks in advance,
Suvra
Hello all,
Web Service Callouts are not supported by test methods. So, in web service callouts we can't get any code coverage. But we can increase the code coverage to a maximum level by modularizing the code.
Say, before making the callout we'll be preparing the request and after receiving output response will be formed.
So, we can have three separate methods for this purpose..
1. for Request forming
2. for Callout - this method will just contain the line which is actually making the call
3. for forming Response.
Now, in test method #1 will get covered, #2 and #3 will be left uncovered. Here we can form manual response and call method #3. This way only minimum no. of lines will be left untouched and coverage will be increased.
Thanks and Regards,
Suvra
All Answers
Hello,
I'm running into the same issue. I have a bunch of methods using HttpRequest to call a web service and won't be able to achieve 75%+ test coverage if I can't test any of these methods.
What is a solution / alternative to testing these methods?
Thanks,
Dan
Hi,
put me in the bag too.
Need to pass the 75% in code coverage calling external webservices.
Hello all,
Web Service Callouts are not supported by test methods. So, in web service callouts we can't get any code coverage. But we can increase the code coverage to a maximum level by modularizing the code.
Say, before making the callout we'll be preparing the request and after receiving output response will be formed.
So, we can have three separate methods for this purpose..
1. for Request forming
2. for Callout - this method will just contain the line which is actually making the call
3. for forming Response.
Now, in test method #1 will get covered, #2 and #3 will be left uncovered. Here we can form manual response and call method #3. This way only minimum no. of lines will be left untouched and coverage will be increased.
Thanks and Regards,
Suvra
Needing to change an automatically generated class to get it by testing is absurd. Whoever stumbles on this post, please promote the ideas related to this topic on the ideas exchange (e.g. http://ideas.salesforce.com/article/show/10090248
Koen.