folks, I have a scheduled class from which I am calling my future method but I am not able to increase test coverage for certain section please help me with it.
Scheduled class (100 % covered)
global class ActivateCFSUsers Implements Schedulable {
public Interface IScheduleDispached {
void execute(SchedulableContext sc);
}
global void execute(SchedulableContext SC) {
Type targetType = Type.forName('HANDLERNAME');
if(targetType != null){
IScheduleDispached obj =(IScheduleDispached)targetType.newInstance();
obj.execute(sc);
}
}
}
HANDLER CLASS That is being called (75% covered)
public class HANDLERNAME implements ActivateCFSUsers.IScheduleDispached {
public void execute(SchedulableContext sc) {
List<User> newusers = [Select Id,CFS_Activation_Date__c from user where (Profile.Name='CTCT Solution Provider (Login Based)'OR Profile.Name='CTCT Solution Provider (Named)')AND lmscons__Cornerstone_ID__c=NULL AND lmscons__CFS_Status__c='Not CFS user'];
Set<Id> sendset = new Set<Id>();
for(integer i=0;i<newusers.size();++i)
// Next line is not covered
sendset.add(newusers[i].Id);
if(newusers.size()>0)
System.debug(newusers.size()+' new users found will give them license in a sometime');
if(newusers.size()>0)
//Next line which is call to my future method is not covered
UserHandler.enrollCFSUser(sendset);
}
}
Test Class (I am not testing anything as of now my first objective is to increase coverage)
@isTest
private class testsActivateCFSUsers {
@isTest
private static void test() {
Test.StartTest();
ActivateCFSUsers sh1 = new ActivateCFSUsers();
String sch = '0 0 23 * * ?';
system.schedule('Test Territory Check', sch, sh1);
Test.stopTest();
}
}