+ Start a Discussion
SFDC Apex DevSFDC Apex Dev 

could anyone help me to write test class for the below batch class...

global class BatchClassSending implements Database.Batchable<sObject>,Database.AllowsCallouts {

    global void execute(Database.BatchableContext BC,List <sObject> scope){
        system.debug('scope>>>>>'+scope);
     list<S_Order__c> approvedO_List = (list<S_Order__c>)scope;
     set<Id> woId_List= new set<Id>();
     
         if(System.Now().minute() > 12 && System.Now().minute() < 15 && !Test.isRunningTest() )
         System.abortJob(bc.getJobId());

     for(S_Order__c oObj:approvedW_List){
        woId_List.add(oObj.Id);
     }
     
     if(!woId_List.isEmpty()){
        P_Sending.sendingODetailOnApprovalofO(woId_List);
     }
    }    
}
Raj VakatiRaj Vakati
Try this
 
@isTest
private class UpdateContactAddressesTest {
    @testSetup 
    static void setup() {
		List<S_Order__c> orderList = new List<S_Order__c>() ;
		for(Integer i =0 ; i<10 ;i ++){
       S_Order__c s = new S_Order__c() ;
	   s.Name = 'Tets';
	   orderList.add(s);
		}
		insert orderList ;
    }
    static testmethod void test() {        
        Test.startTest();
        BatchClassSending  uca = new BatchClassSending ();
        Id batchId = Database.executeBatch(uca);
        Test.stopTest();
      
    }
    
}