Search code examples
muleanypoint-studiomunit

Test a Batch Flow in MUnit


I am trying to test a batch flow but if I place a reference to a batch flow in my MUnit test, the test will finish instantly and run the asserts, while the batch flow continues in the background. Is there a way to force my batch job to run synchronously so that I can examine the results in my MUnit tests?


Solution

  • Here is an app showing how to do just that: https://www.mulesoft.com/exchange#!/munit-testing-batch-module

    The way to achieve it is to use the following MUnit component: https://docs.mulesoft.com/munit/v/1.2.0/run-and-wait-scope

    HTH