if(!test.isrunningtest()){
try{
String day = string.valueOf(system.now().adddays(2).day());
String month = string.valueOf(system.now().adddays(2).month());
String hour = string.valueOf(system.now().adddays(2).hour());
String minute = string.valueOf(system.now().adddays(2).minute());
String second = string.valueOf(system.now().adddays(2).second());
String year = string.valueOf(system.now().adddays(2).year());
String strJobName1 = 'Job-' + second + '_' + minute + '_' + hour + '_' + day + '_' + month + '_' + year;
String strSchedule1 = '0 ' + minute + ' ' + hour + ' ' + day + ' ' + month + ' ?' + ' ' + year;
System.debug('@@@@@@@@'+strSchedule1);
id cronid = System.schedule(strJobName1,strSchedule1, new scheduledTest1(c.id));
Schedule_Abort__c sb = new Schedule_Abort__c();
sb.name = cronid;
sb.Casenumber__c =c.id;
Scheduleaborts.add(sb);
}
catch(exception e){
Logger.LogMessageWithException('Exception occurred while Sending Auto Acknowledgement', '', e);
}
1 Answer
test.isrunningtest()
is specifically used to skip codes which will fail during test class execution or doesn't applies to test coverage.
I guess you don't want to schedule your job during test execution that's why you have added it inside test.isrunningtest()
block.
Just to increase your test coverage, why dont you put ONLY the below code under test.isRunningTest() block?
id cronid = System.schedule(strJobName1,strSchedule1, new scheduledTest1(c.id));
Schedule_Abort__c sb = new Schedule_Abort__c();
sb.name = cronid;
sb.Casenumber__c =c.id;
Scheduleaborts.add(sb);
Rest of your code can run safely during the test execution.
if(!test.isrunningtest())
test.isRunningTest()
even in this prod class?