Find your content:

Search form

You are here

Can/should we use assert statement in a test class for batch processes?


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.


Attribution to: Prady

Possible Suggestion/Solution #1

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

   BatchClassName bc= new BatchClassName ();
    Database.executeBatch(bc, 200);

Attribution to: Prady
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content