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.

  • 1
    All I can think is that there must be another call out occuring in another part of your code. Have you taken a detailed look at the debug log from the test execution? Jun 4 '13 at 7:45

Saw this on another post, have not tested it.

if (!System.Test.isRunningTest()) {
else {
  // Simulate callout here...

My solution: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_testing_httpcalloutmock.htm

Note: callout mock type depends by the type of web service that do you have.

Thanks to all!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.