We have a problem in our organization and I was hoping for some advice from you on how to best tackle this.

We have a handler class that makes a callout to a Master Data Management system for account validation. That handler class is perfectly covered by it's own tests that utilize Mocking of the outbound call.

Now our business process dictates that we need to do a check every time an Account is created or updated, so we invoke that callout from an Account After trigger.

Now we run into a problem as any testmethod we have in the system that tries to construct an Account for unit testing purposes triggers the outbound callout and fails with a Fatal error: testmethods cannot invoke callouts.

Can somebody give us a hint on how to best properly deal with this?

Best regards, Ivar

  • How did you implement async callout from trigger? Do you use future annotation, implement Queueable interface? Nov 28, 2017 at 13:01
  • It is @future but not queueable Nov 28, 2017 at 13:09

1 Answer 1


In your trigger handler class AccountTriggerHandler create static field

private static Boolean skipCallout = Test.isRunningTest();

and then before making a callout check:

    // do callout
  • Thanks Alexander! We were thinking along those lines. Good to get confirmation by a third party! Nov 28, 2017 at 13:50

You must log in to answer this question.

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