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.



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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.