Activity Forums Salesforce® Discussions Can we write test class for a shedulable batch class in Salesforce?

  • Piyush

    Member
    September 13, 2019 at 2:42 am

    Hi Deepak,

    Yes, We can write test class for a shedulable batch class in Salesforce:-

    For Example:-

    @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