0

I have a Batch process which updates a field on Account. I have also written a test class for it. I have an assert statement to check if the field is getting updated.

Unfortunately this assert fails, this i would think is because the batch probably doesnt get executed immediately. Is there a way confirm that the batch is executed and only then do the asserts.

Thanks

1 Answer 1

5

The answer is to enclose the running of the batch file within startTest and StopTest methods

 System.Test.startTest();
   BatchClassName bc= new BatchClassName ();
    Database.executeBatch(bc, 200);
 System.Test.stopTest();

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .