function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JamesT77JamesT77 

Test Trigger that contains callout

hi

 

i've read up on how you can test callout code (Virtual Callout Testing) and tried to use it within a trigger.

 

However this code does not work when you try to call it within a trigger.

 

To fire the callout method within the trigger you have to fire it asynchronously using the @Future tag and the method has to be static also. This breaks the virtual classes. 

 

Has anyone got the Virtual Callout Testing code to work within a trigger also?

spraetzspraetz

In your testmethod, did you use the Test.startTest() and Test.stopTest() methods? 

 

To test @future methods, you need to use those.  See the Apex doc for more information.