Test class for Schedulable class in Salesforce

Sample :

@istest
public with sharing class SampleTest {
    static testmethod void testSample() {
        Test.startTest();
        Datetime dt = Datetime.now().addMinutes(1);
        String CRON_EXP = '0 '+ dt.minute() + ' * ' + dt.day() + ' ' + dt.month() + ' ? ' + dt.year();
        String jobId = System.schedule('Sample_Heading', CRON_EXP, new Schedulable_Class() );   
        Test.stopTest();
    }

}

Cheers!!!

No comments:

Post a Comment