You need to sign in to do that
Don't have an account?
Shanmuga Prasath Pushpanathan
how to use constructor with two parameters in batch apex and how to write test class for the same?
While covering the below batch apex im getting a error 'System.UnexpectedException: Start did not return a valid iterable object.'
I exected the batch class like:
batchClass b = new batchClass(idSet, stringMap);
Database.executeBatch(b,1);
Batch class:
global class batchClass implements Database.Batchable<sObject>{
Set<Id> idSet = new Set<Id>();
Map<String, String> stringMap = new Map<String, String>();
public batchClass(Set<Id> idSet, Map<String, String> stringMap){
this.idSet = idSet ;
this.stringMap = stringMap;
}
global Database.QueryLocator start(Database.BatchableContext BC){
String query = 'Query';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<sObject> scope) {
//logic
}
global void finish(Database.BatchableContext BC) {}
}
I exected the batch class like:
batchClass b = new batchClass(idSet, stringMap);
Database.executeBatch(b,1);
Batch class:
global class batchClass implements Database.Batchable<sObject>{
Set<Id> idSet = new Set<Id>();
Map<String, String> stringMap = new Map<String, String>();
public batchClass(Set<Id> idSet, Map<String, String> stringMap){
this.idSet = idSet ;
this.stringMap = stringMap;
}
global Database.QueryLocator start(Database.BatchableContext BC){
String query = 'Query';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<sObject> scope) {
//logic
}
global void finish(Database.BatchableContext BC) {}
}
Jayant
What you pasted looks good, seems the actual code has issues. Can you paste the actual code rather than pseudo code ?