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
pintoo rajputpintoo rajput 

How to write a Test Class for a Batch Apex Class???

AshwaniAshwani
Look at follwing link. It would help you:

http://www.salesforce.com/us/developer/docs/apex_workbook/Content/apex_batch_2.htm
Bindhyachal Kumar SinghBindhyachal Kumar Singh
Hi Pintoo,

You can use following sample code:

@isTest
public class CreateUpdateInvoiceStagingBatchTest {
    testMethod static void testCreateUpdateInvoiceStagingBatch () {   

        Account acct = new Account(Name='CreateUpdateInvoiceStagingBatch Test');
        insert acct;
       
        Test.startTest(); 
            // Below line can be used to execute a batch in test class.
            Database.executeBatch(new CreateUpdateInvoiceStagingBatch(), 1);      
            CreateUpdateInvoiceStagingBatch.isApexTest=false;
            CreateUpdateInvoiceStagingBatch.scheduleJob();
        Test.stopTest();
    }
}