Activity Forums Salesforce® Discussions how to write test class for a scheduler class in salesforce?

  • Piyush

    Member
    September 11, 2019 at 5:24 am

    Hi Deepak,

    You can write test class for a scheduler class in salesforce like this:-

    @isTest
    public class testScheduleBatch{  
    
        public static testmethod void first1(){
            Test.startTest();
            Datetime dt = Datetime.now().addMinutes(1);
            String CRON_EXP = '0 '+ dt.minute() + ' * ' + dt.day() + ' ' + dt.month() + ' ? ' + dt.year();
            testScheduleBatch.SchedulerMethod('Sample_Heading', CRON_EXP, new ScheduleBatch () );   
            Test.stopTest();
        }  
    
    }

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos