here is the Apex class:
global class GroupBatchSchedule implements Schedulable {
global void execute(SchedulableContext sc) {
GroupBatch b = new GroupBatch();
if(!Test.isRunningTest())
database.executebatch(b);
}
}
Here is its test class:
@isTest
Public class GroupBatchScheduleTest{
public static testMethod void testschedule() {
Test.StartTest();
GroupBatchSchedule testsche = new GroupBatchSchedule();
String sch = '0 0 23 * * ?';
system.schedule('Test', sch, testsche );
Test.stopTest();
}
}
NOTE: if I do not use if(!Test.isRunningTest()) in the apex class the its code coverage is 100% but failing with the error: System.UnexpectedException: No more than one executeBatch can be called from within a test method. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation.