3

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.

1
  • 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, 2013 at 7:45

2 Answers 2

4

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!

3

Saw this on another post, have not tested it.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .