You need to sign in to do that
Don't have an account?
Sanjat Samal 8
Test Class For Schedule Class
How to write a test class for schedule apex class? For Below Code.
global class ClearHistoricalAccountCaseScheduler implements Schedulable
{
global void execute(SchedulableContext SC)
{
System.debug('ClearHistoricalAccountCaseScheduler Start...');
List<Account> accountList = [Select Case_Life__c From Account Where Case_Life__c != '3 Years' and Case_Life__c != '2 Years'];
Integer accountIndex = 0;
if(accountList.size() > accountIndex)
{
ClearHistoricalAccountCaseBatch batchDelete = new ClearHistoricalAccountCaseBatch();
batchDelete.accountList = accountList;
batchDelete.accountIndex = accountIndex;
ID batchProcessId = Database.executeBatch(batchDelete, 200);
System.debug('Returned Batch Process ID: ' + batchProcessId);
}
System.debug('ClearHistoricalAccountCaseScheduler Stop...');
}
}
Thanks
global class ClearHistoricalAccountCaseScheduler implements Schedulable
{
global void execute(SchedulableContext SC)
{
System.debug('ClearHistoricalAccountCaseScheduler Start...');
List<Account> accountList = [Select Case_Life__c From Account Where Case_Life__c != '3 Years' and Case_Life__c != '2 Years'];
Integer accountIndex = 0;
if(accountList.size() > accountIndex)
{
ClearHistoricalAccountCaseBatch batchDelete = new ClearHistoricalAccountCaseBatch();
batchDelete.accountList = accountList;
batchDelete.accountIndex = accountIndex;
ID batchProcessId = Database.executeBatch(batchDelete, 200);
System.debug('Returned Batch Process ID: ' + batchProcessId);
}
System.debug('ClearHistoricalAccountCaseScheduler Stop...');
}
}
Thanks
Reffer this link for your solution:
Link: http://amitsalesforce.blogspot.com/2017/07/how-to-write-test-class-for-scheduler.html