How to create a class object in different class's method and return its object. The class is a batchClass whose object needs to be created and returned in different class.
My code so far:
public static Object createBatchObj(arg1,arg2) {
String status = null;
Object batchObj = null;
if(arg1,arg2 condition) { batchclass1 batchObjNew = new batchclass1); }
if(arg1,arg2 condition) { batchclass2 batchObjNew = new batchclass2(); }
else { status = 'Wrong value entered'; }
return batchObj;
}
But while using it here in a test class this error comes
--at line 29 Error: Compile Error: Method does not exist or incorrect signature: [void].start(Database.BatchableContext)
Test.startTest();
Database.insert(accList);
batchObj.start(batchContext); //<------------Line 29
batchObj.execute(batchContext,accList);
Object batchObj = null; batchObj = new batchclass1();