function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Manoj ReddiManoj Reddi 

How to write Test Coverage for this class ?

 global class scheduledMerge implements Schedulable
{
   public string no;
   global void execute(SchedulableContext SC) 
   {
      for(Integer i=1;i<=24;i++)
      {
            Date dt=System.today().addmonths(-i);
            no=string.valueof(i);
            Id batchInstanceId = Database.executeBatch(new BatchA(string.valueof(dt.month()),String.valueof(dt.Year()),no), 200);
       }
   } 
}
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for scheduler test class
1) https://developer.salesforce.com/docs/atlas.en-us.apex_workbook.meta/apex_workbook/apex_scheduling_2.htm
@isTest
private class scheduledMergeTest 
{
	public static String CRON_EXP = '0 0 0 15 3 ? 2022';
	static testmethod void test() 
	{
		// Create test class for your test class
	
		String jobId = System.schedule('scheduledMerge', CRON_EXP,  new scheduledMerge());
    	CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered,  NextFireTime  FROM CronTrigger WHERE id = :jobId];
		System.assertEquals(CRON_EXP,   ct.CronExpression);
	}
}

Let us know if this will help you