[SalesForce] TestMethod do not support Web service callouts, test skipped

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.

Best Answer

Saw this on another post, have not tested it.

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