I have written an scheduler class inside which I have methods too, so that I can schedule the same class at different schedule time and the methods works based on current time, MY CODE
global class testclass Implements Schedulable
{
global void execute(SchedulableContext sc)
{
String t= String.valueOf(System.now());
integer t1 = integer.valueOf(t.substring(11,13));
if(t1<13)
{
morningfn();
}
else
{
eveningfn();
}
}
morningfn()
{
//CODE
}
eveningfn()
{
//CODE
}
}
I have Scheduled the small class twice a day i.e.morning 8 and evening 5 so it will class the function based on the current time and this is working fine. but while writing test class
@isTest
public class testclasstest {
@isTest Static void test1(){
testclass tc = new testclass ();
String sch = '0 30 10 * * ?';
System.schedule('morning', sch, tc);
System.schedule('evening', sch, tc);
}
}
When I execute this test it ll be always 53% based on what time executing either before 13 i.e.1PM (Morning function) or after 13 (evening function).
I can achieve 100% if i remove if-then or make 2 different class or scheduler class but i want to achieve everything in single class.
is there any way I can call function name in system.schedule method???? or any other solution Plz Help. Thank You in advance.