We are going to update the order name using batch class.
Scheduler Class:
global class OrderUpdate implements Database.Batchable {
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(‘Select Id, Name From Order’);
}
global void execute(Database.BatchableContext BC, List scope){
for(Order o: scope){
o.Name += ‘ Updated’;
}
update scope;
}
global void finish(Database.BatchableContext BC){}
Test Class:
@isTest
private class ordListountUpdate {
static testmethod void test() {
// Create test accounts to be updated
// by the batch job.
Order[] ordList = new List<Order>();
for (Integer i=0;i<200;i++) {
Order m = new Order(Name = ‘Order ‘ + i);
ordList .add(m);
}
insert ordList;
Test.startTest();
OrderUpdate c = new OrderUpdate();
Database.executeBatch(c);
Test.stopTest();
}
We are the ISV Partners and Please reach us for custom development => www.merfantz.com
————————————Hope this will help you!—————————————-