You need to sign in to do that
Don't have an account?
EtienneCoutant
How to write test for Apex Scheduler
Hi,
I have created a Class that implements the Schedulable interface for a batch Apex class called batchable:
global class scheduledBatchable implements Schedulable{ global void execute(SchedulableContext sc) { batchable b = new batchable(); database.executebatch(b); } }
Now I am not sure how I can write my test class... Can i call execute() ? What should be the SchedulableContext?
Take a look at the docs:
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_scheduler.htm?SearchType=Stem
Per the example, you can validate the cron expression by validating the next fire time. Similar to Batch and @future, you can invoke the scheduler after Test.startTest() and assert the execute behavior after Test.stopTest().