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
arunatascarunatasc 

im having problem to write test class for a scheduler. Can u please assist?

This is the scheduler we have:

 

global class ScheduleImportData implements Schedulable {
   
    global void execute(SchedulableContext context) {
       ImportExcelWebservice.getExcelDetails();
    }

}

 

 

We need to write test class.  How can we write we need to do this by today end!

Best Answer chosen by Admin (Salesforce Developers) 
dev401hasdev401has

As per my understanding, you have written another class ImportExcelWebservice in which you have mentioned method getExcelDetails().

 

I would suggest that if possible write the method getExcelDetails() in your class ScheduleImportData  only.

 

and then test method will be fairly simple:

 

public static testMethod void testScheduleImportData () {  
       
        ScheduleImportData sid =new ScheduleImportData ();
        sid.getExcelDetails();
         
    }

 

I guess this should work.

All Answers

dev401hasdev401has

As per my understanding, you have written another class ImportExcelWebservice in which you have mentioned method getExcelDetails().

 

I would suggest that if possible write the method getExcelDetails() in your class ScheduleImportData  only.

 

and then test method will be fairly simple:

 

public static testMethod void testScheduleImportData () {  
       
        ScheduleImportData sid =new ScheduleImportData ();
        sid.getExcelDetails();
         
    }

 

I guess this should work.

This was selected as the best answer
arunatascarunatasc

Thank q for your reply. I will try today!

I tried with same type of code in importexcel scheduler which didn't worked.  Some mistake may be there in my code! 

I will try with your code!