I have a batch class which is called by an scheduler class which is scheduling itself. I have written a test class which has two methods: One tests the batch and the other the scheduler.Overall the test passed and the batch class code coverage is good and the scheduler class's second method(execute method) is also covered in test class but the first method which is there to schedule itself is not getting covered. Please help. My scheduler class code:
global class ContUpdateScheduler implements Schedulable{
global static String cronExp = '0 0 13 * * ? *';
**This method is not getting covered**
global static String scheduleMe(){
ContUpdateScheduler scheduler = new ContUpdateScheduler();
return System.schedule('Update Contacts', cronExp, scheduler);
}
global void execute(SchedulableContext sc){
ContactUpdateBatch batchable = new ContactUpdateBatch();
Database.executeBatch(batchable, 100);
}
}
My testclassmethod for testing the scheduler:
@istest
public static void testSchedule() {
String sch = '0 0 13 * * ? *';
ContUpdateScheduler testsche = new ContUpdateScheduler();
//string fetchID = testsche.scheduleMe();
Test.StartTest();
string JobId = system.schedule('Test status Check', sch, testsche );
Test.stopTest();
}