You need to sign in to do that
Don't have an account?
Vishal Tiwari 36
How to cover exception in execute method for batches in the test classes?
global void execute(Database.BatchableContext BC, List<OBJ__c> objList) {
try{
if(objList!= null && objList.size() > 0 ){
delete objList;
}
}
catch(Exception ex){
System.debug('Exception');
}
}
try{
if(objList!= null && objList.size() > 0 ){
delete objList;
}
}
catch(Exception ex){
System.debug('Exception');
}
}
Create a record for OBJ__c before using execute batch that will be retrieved on your start method.
Validate that whatever you have on your start method query is returning data.
if it helps please like and mark as correct, as it may help others.