Activity Forums Salesforce® Discussions How to test Future methods in Salesforce?

  • PRANAV

    Member
    December 20, 2016 at 2:18 pm

    Hi Sushant,

    You must use startTest() and stopTest(). All asynchronous calls made after the startTest() method are collected by the system. When stopTest() is executed, all asynchronous processes are run synchronously.

    Simply call your @future method in-between these, and then make your asserts after the stopTest().

    The stopTest() will cause the @future method to fire, and the next statement can verify the functionality you developed in your future method.

    Hope this helps you.

    Thanks

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos