You need to sign in to do that
Don't have an account?
Enry
TestMethod do not support Web service callouts, test skipped
Hi ,
I have written a test class for a trigger on the lead object.
When i run the test class i get the following error:
Methods defined as TestMethod do not support Web service callouts, test skipped
There is an other trigger on lead that has a call to a webservice so i get this error.
I have wrapped the call with:
if (!Test.isRunningTest()) { // do callout }
But i’m still getting the same error.
Any other way to run correctly the test class?
Thank you in advantage.
BR.
Anyways you can give a try to HttpCalloutMock interface for testing, more precisely real unit testing.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_testing_httpcalloutmock.htm
Thank you very much for you reply.
Pleace Can you explain in more detail your solution.
I don't know anything about HttpCallout.
This is my test class:
What code should i insert to give a HttpCalloutMock interface to the test class?
Thanks.
Make sure there are only one webservice.
My Suggestion : Look for other triggers and check whether they have webservice calls associated with them.
I can't tell you about the webservice call by having a look at the test class
Thank you again!
I don't find other triggers on lead with a call to a webservice.
I think that there are other classes that have calls.
Do yo think is a good solution to find all the calls(in classes and triggers) to the webservice and wrapper them?
If you are running a single test class(this one) at a time and it still gives you an error, it means that there is another trigger which is having the callout
Yes, i'm running just my test class(from select test).
I looked at the code for all triggers on lead but nothing.
I'm looking also in the debug log but i am not able to find what other trigger is executed.
I deleted the trigger because it was old and no longer needed.
But i'm still getting the error.
I have another call in an trigger on user object;in the log i see that there is a call from this trigger.
But i don't understand why i'm executing also a trigger on user.
have i to wrapper also the call that there aren't make from triggers on lead?
If you have a close look at your test class you will find that it is doing DML @User object
You should be following the best practices for test method and write test classes accordingly like wrapping httpmock etc.