---
schema_version: "1"
id: 6869d3bf2a5a5a021644640f7e750f3ea7921e085e67159b96de1854eff6af9e
title: Test a Flow with a Scheduler Source in MUnit
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/munit/latest/test-flow-with-scheduler-cookbook.md
canonical_url: https://docs.mulesoft.com/munit/latest/test-flow-with-scheduler-cookbook
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 54ea2c2e697e7b0fa486cbaf782e826b01aa269147d7ca3977bba7b569e592bb
description: MuleSoft Documentation Site
release: "3.7"
latest: true
---
---
product: MUnit
version: 3.7
is-latest-version: true
---

# Test a Flow with a Scheduler Source in MUnit

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

![logo acb active](/mulesoft/current/en-us/_/img/icons/anypoint-code-builder.svg "Anypoint Code Builder")Anypoint Code
Builder

![logo studio active](/mulesoft/current/en-us/_/img/icons/studio.svg "Anypoint Studio")Anypoint Studio

Test a Mule flow triggered by a Scheduler component in MUnit by enabling flow sources and using the
verify-call processor to confirm the flow executes. Wrap verify-call inside an until-successful
scope to handle timing variations in the Scheduler.

Assume that you want to both test the following flow triggered by a Scheduler component and validate
that your flow is being triggered correctly:

```xml
<flow name="schedulerFlow">
    <scheduler>
        <scheduling-strategy >
            <fixed-frequency frequency="10" timeUnit="SECONDS"/>
        </scheduling-strategy>
    </scheduler>
    <set-payload value="#['test poll']"/>
</flow>
```

1.  Enable flow sources.  
    Because MUnit does not start any of the flow sources (such as triggers or listeners), you must
    configure which flow sources start for your tests.

    In this example, you enable the flow that contains the Scheduler:

    ```xml
    <munit:test name="test-schedulerFlowTest">
        <munit:enable-flow-sources>
            <munit:enable-flow-source value="schedulerFlow"/>
        </munit:enable-flow-sources>
    </munit:test>
    ```

2.  Verify that flow execution is triggered by the Scheduler.  
    To verify that the processors inside your flow are being triggered, use the
    `munit-tools:verify-call` processor.

    Wrap `munit-tools:verify-call` inside an `until-successful` to shorten processing time when the
    Scheduler is not operating when you want to test.

    The following example validates three times that the payload was executed at least once during
    the test.

    ```xml
    <munit:execution>
        <until-successful maxRetries="3" millisBetweenRetries="100">
            <munit-tools:verify-call processor="set-payload" atLeast="1">
                <munit-tools:with-attributes >
                    <munit-tools:with-attribute whereValue="#['test poll']" attributeName="value" />
                </munit-tools:with-attributes>
            </munit-tools:verify-call>
        </until-successful>
    </munit:execution>
    ```

## See Also

- [Enable Flow Sources](https://docs.mulesoft.com/munit/latest/enable-flow-sources-concept)

- [Verify Event Processor](https://docs.mulesoft.com/munit/latest/verify-event-processor)
