I am trying to deploy a new piece of Apex that conducts some internal Salesforce operations (inserting a number into a field based on another field).

The test involves inserting a lead into Salesforce, running the script and then asserting if it made the desired change.

I wrote the test for it, got 80% coverage and was deploying from Sandbox into Production when I started getting callout errors ('Method does not support web service callouts'). The problem I am having is that I also have some triggers that get triggered upon insert of a new lead and make external http callouts to various APIs.

How do I handle for them? Do I need to include mock Http callout class within this test even though it's 100% internal to Salesforce? Why do I need even handle those triggers if my deployment has nothing to do with them? Any way I can isolate this test and stop the callouts from happening?

  • So there are Leads that are qualifying for service call outs that shouldn't? – EricSSH Jul 6 '17 at 16:48
  • Are the same triggers that are causing a problem in production also in the sandbox? Why aren't they also causing the test cases to fail in the Sandbox? – Daniel Ballinger Jul 7 '17 at 2:00
  • Generally I'd have either a way to disable the triggers in the test context, or have the callouts detect that they are in a testing context and that no mock has been configured. – Daniel Ballinger Jul 7 '17 at 2:01

Your Answer

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

Browse other questions tagged or ask your own question.