You need to sign in to do that
Don't have an account?
How to cover webservice callout functions in test methods?
I have a class which contains functions that are used to make
webservice callouts only. I need to cover these functions in my test
methods but "Run Test" fails after running the first function with the
following message:
(Older API) Methods defined as TestMethod do not support Web service callouts, test skipped
(NEW API - 15) System.TypeException: Testmethods do not support webservice callouts.
in
this scenario I need to know how I can obtain the required coverage
(75%) on my Apex class. is there anyway that I can ignore callouts but
force the test method to continue? in my class more than 75% of the
code is the functions that each make a callout to an external
webservice. any Idea?
Thanks
P.S: I have searched the forum and this has been posted several times but no answer yet.
try puting yours webservice call outs usinf istestexcution
try
{
web service callouts
yours code
if(!isTestExcution)
}
catch {
exceptions
}
check yours response code in the if condition (this code is varies depends on problem).try it.
Hi,
This could be a nice solution if it was working ;) when I use it I get the following error:
Error: Compile Error: Variable does not exist: isTestExecution at line 9 column 17
do you have any reference to this "isTestExecution" system variable? I haven't heard about this before.
Thanks
Their is two ways to implment test coverage for webservice callout testing the test excution other one is according to their documentation.see the test coverage documentation they provided how to implement webservice callouts and test coverage.thanks
Please, use this in your test method and all will be resolved....
Here is the link to the implementation this uses:
http://www.salesforce.com/us/developer/docs/apexcode/index.htm
Here is the section that covers this in general:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_testing.htm
May The SForce Be With You!
Nathan Pepper
youtube.com/MayTheSForceBWithYou
@SForceBeWithYou