You need to sign in to do that
Don't have an account?
Runi
code coverage test class
How to write test class for below class.
public with sharing class RecordsBatch implements Database.Batchable<sObject>,Schedulable{
public Database.QueryLocator start(Database.BatchableContext pBatchContext) {
system.debug('\n\n Label.RecordsBatchQueryOnFeeSplit :: '+Label.RecordsBatchQueryOnFeeSplit);
return Database.getQueryLocator(Label.RecordsBatchQueryOnFeeSplit);
}
public void execute(Database.BatchableContext pBatchContext, List<bank__C> listFeeSplit) {
system.debug('...listFeeSplit...'+listFeeSplit);
List<bank__C> UpdateFeeSplit = new List<bank__C>();
for(bank__C oppFS: listFeeSplit){
bank__C UpdateObjFS = new bank__C();
system.debug('WIP*****');
if(oppFS.Recipient__r.Service_Line__c != oppFS.Recipient_Service_Line__c
|| oppFS.Recipient__r.Business_Unit__c != oppFS.Recipient_Business_Unit__c
|| oppFS.Recipient__r.Revenue_Generating_Team__c != oppFS.Recipient_Revenue_generating_team__c;
|| oppFS.Recipient__r.RGT_ID__c != oppFS.Recipient_RGT_ID__c){
UpdateObjFS.id = oppFS.ID;
UpdateObjFS.Recipient_Service_Line__c = oppFS.Recipient__r.Service_Line__c;
UpdateObjFS.Recipient_Business_Unit__c = oppFS.Recipient__r.Business_Unit__c;
UpdateObjFS.Recipient_Revenue_generating_team__c = oppFS.Recipient__r.Revenue_Generating_Team__c;
UpdateObjFS.Recipient_RGT_ID__c = oppFS.Recipient__r.RGT_ID__c;
system.debug('WIP UpdateObjFS*****'+UpdateObjFS);
UpdateFeeSplit.add(UpdateObjFS);
}
}
if(!UpdateFeeSplit.isEmpty()){
Database.update(UpdateFeeSplit,false);
}
}
public void execute(SchedulableContext ctx) {
RecordsBatch oWB = new RecordsBatch();
database.executebatch(oWB,Integer.valueof(Label.RecordsBatchLimit));
}
public void finish(Database.BatchableContext bc){
}
}
public with sharing class RecordsBatch implements Database.Batchable<sObject>,Schedulable{
public Database.QueryLocator start(Database.BatchableContext pBatchContext) {
system.debug('\n\n Label.RecordsBatchQueryOnFeeSplit :: '+Label.RecordsBatchQueryOnFeeSplit);
return Database.getQueryLocator(Label.RecordsBatchQueryOnFeeSplit);
}
public void execute(Database.BatchableContext pBatchContext, List<bank__C> listFeeSplit) {
system.debug('...listFeeSplit...'+listFeeSplit);
List<bank__C> UpdateFeeSplit = new List<bank__C>();
for(bank__C oppFS: listFeeSplit){
bank__C UpdateObjFS = new bank__C();
system.debug('WIP*****');
if(oppFS.Recipient__r.Service_Line__c != oppFS.Recipient_Service_Line__c
|| oppFS.Recipient__r.Business_Unit__c != oppFS.Recipient_Business_Unit__c
|| oppFS.Recipient__r.Revenue_Generating_Team__c != oppFS.Recipient_Revenue_generating_team__c;
|| oppFS.Recipient__r.RGT_ID__c != oppFS.Recipient_RGT_ID__c){
UpdateObjFS.id = oppFS.ID;
UpdateObjFS.Recipient_Service_Line__c = oppFS.Recipient__r.Service_Line__c;
UpdateObjFS.Recipient_Business_Unit__c = oppFS.Recipient__r.Business_Unit__c;
UpdateObjFS.Recipient_Revenue_generating_team__c = oppFS.Recipient__r.Revenue_Generating_Team__c;
UpdateObjFS.Recipient_RGT_ID__c = oppFS.Recipient__r.RGT_ID__c;
system.debug('WIP UpdateObjFS*****'+UpdateObjFS);
UpdateFeeSplit.add(UpdateObjFS);
}
}
if(!UpdateFeeSplit.isEmpty()){
Database.update(UpdateFeeSplit,false);
}
}
public void execute(SchedulableContext ctx) {
RecordsBatch oWB = new RecordsBatch();
database.executebatch(oWB,Integer.valueof(Label.RecordsBatchLimit));
}
public void finish(Database.BatchableContext bc){
}
}
Refer the below link will help you to create test class for batch class.
https://jayakrishnasfdc.wordpress.com/2021/01/02/apex-test-class-for-batch-apex/
Let me know if any issues, will help you with code.
If this helps, Please mark it as best answer.
Thanks!!
try with below code sample and keep the mandatory data.
If this helps, Please mark it as best answner.
Thanks!!