0

I need to run batch (or something else which will process big amount of records) and after this branch I need to invoke

System.assert(booleanVariable);

How can I do this? Batch need to execute and finish before this block of code.

1 Answer 1

3

Using startTest and stopTest will allow you to assert once the batch operation is completed.

Test.startTest();
// invoke batch
Test.stopTest();
// assert results

Asynchronous calls made during the test are finalised when you call Test.stopTest() allowing you to test the results of asynchronous logic.

All asynchronous calls made after the startTest method are collected by the system. When stopTest is executed, all asynchronous processes are run synchronously.

You must log in to answer this question.

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