Test class for Schedulable class in Salesforce

Test class for Schedulable class in Salesforce

Following code can be used to call the Apex Scheduler Class instantly.

Schedulable_Class obj = new Schedulable_Class();  
obj.execute( null );  

Sample Code to run Apex Schedule Class instantly:

So, we can use the same in the test class to run the Apex Schedulable class instantly.

Sample:

@isTest  
public with sharing class SampleTest {  
  
    static testmethod void testSample() {  
  
        Test.startTest();  
        Schedulable_Class obj = new Schedulable_Class();  
        obj.execute( null );  
        Test.stopTest();  
  
    }  
  
}  

Leave a Reply