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
amateur1amateur1 

test case help

how to write test case for this class

 

 

global class WOW_InventoryAgeing implements schedulable
{
    global void execute(SchedulableContext sc)
    {
   WOW_InventoryAgeing_BatchClass b1 = new WOW_InventoryAgeing_BatchClass(); //ur batch class
      database.executebatch(b1,180);
    }
    
     
}

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

 

try thebelow code snippet as reference:

 

global class WOW_InventoryAgeing implements schedulable
{
global void execute(SchedulableContext sc)
{
WOW_InventoryAgeing_BatchClass b1 = new WOW_InventoryAgeing_BatchClass(); //ur batch class
database.executebatch(b1,180);
}

public static testMethod void WOW_InventoryAgeing()
{

Test.startTest();

WOW_InventoryAgeing m = new WOW_InventoryAgeing();
String sch = '0 0 10 ? * MON-FRI';
String jobId =system.schedule('Merge Job', sch, m);

system.debug('###'+jobId);
// Get the information from the CronTrigger API object

CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered,
NextFireTime FROM CronTrigger WHERE id = :jobId];

Test.stopTest();

}

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

 

try thebelow code snippet as reference:

 

global class WOW_InventoryAgeing implements schedulable
{
global void execute(SchedulableContext sc)
{
WOW_InventoryAgeing_BatchClass b1 = new WOW_InventoryAgeing_BatchClass(); //ur batch class
database.executebatch(b1,180);
}

public static testMethod void WOW_InventoryAgeing()
{

Test.startTest();

WOW_InventoryAgeing m = new WOW_InventoryAgeing();
String sch = '0 0 10 ? * MON-FRI';
String jobId =system.schedule('Merge Job', sch, m);

system.debug('###'+jobId);
// Get the information from the CronTrigger API object

CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered,
NextFireTime FROM CronTrigger WHERE id = :jobId];

Test.stopTest();

}

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

This was selected as the best answer
amateur1amateur1

it works got 100 percent