How to test Batch Class’s execute method alone in Salesforce?

How to test Batch Class’s execute method alone in Salesforce?

Sample Code:


sObject__c sObj = [SELECT Id, FROM sObject__c WHERE your_condition];
Database.BatchableContext bc;
BatchClass obj = new BatchClass();
obj.execute(bc, new List<sObject__c> {sObj});


Similarly you can test start and finish methods too.

Cheers!!!

Leave a Reply