[SalesForce] How to test schedulable job with future method

I have daily job that makes callouts and updates some records. There is @future method invocation in execute() method.
I have created test according to this guide: https://developer.salesforce.com/docs/atlas.en-us.apex_workbook.meta/apex_workbook/apex_scheduling_2.htm

I can see in logs that my schedulable job started, but future method was not covered.

Best Answer

You don't include any of your code, so am taking a bit of a stab here at answering your question. Normally, all @future and schedulable code runs when the test.stopTest() method is called. You should be able to query for your schedulable job in the chronTrigger object to find the number of times it's been run which allows you to assert that your job ran, plus assert the results of the code. The latter should also allow you to assert that the @future method was called in the schedulable job.

Related Topic