function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sai kumar 433sai kumar 433 

please write test class for this thanx adv?

global class BatchAapex1 implements Database.Batchable<Sobject>
{
 global Database.QueryLocator start(Database.BatchableContext bc)
 {
     String query = 'select id,name from Account';
     return Database.getQueryLocator(query);
 }
   global void execute(Database.BatchableContext bc,List<Account> Scope)
   {
       List<Account> acc = new List<Account>();
       for(Account a:acc)
       {
           a.name = 'Mr.' +a.name;
           acc.add(a);
       }
       update acc;
   }
     global void finish(Database.BatchableContext bc)
     {
         
     }
    
    
       
   }
Nayana KNayana K
@isTest
private class UpdateAccNameTest {

    static testmethod void test() {
        Account objAcc = new Account(Name = 'Some Name', BillingState = 'AP', BillingStreet='Tst', BilllingCity='test city',
									BillingCountry='USA', BillingPostalCode='12345');
		insert objAcc;

       Test.startTest();
       Database.executeBatch(new BatchAapex1());
       Test.stopTest();
		
		// verify the result
       System.assertEquals('Mr.Some Name',[SELECT Name FROM Account WHERE Id=: objAcc.Id].Name);
    }
}

Please mark this as solved.
Vasani ParthVasani Parth
++ .  I think you need to read below link it helps you

http://www.salesforce.com/us/developer/docs/apex_workbook/Content/apex_batch_2.htm