<munit:test name="sampleTest" description="Test">
<mock:when messageProcessor="mule:set-payload">
<mock:then-return payload="#['Sample']"/>
</mock:when>
<flow-ref name="sampleFlow"/>
<munit:assert-payload-equals expectedValue="#['SampleString']"/>
</munit:test>
Migrating Test Structure (MUnit)
Standard Support for Mule 4.1 ended on November 2, 2020, and this version of Mule reached its End of Life on November 2, 2022, when Extended Support ended. Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted. MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements. |
The MUnit test is divided into three scopes. All of them are optional:
Scope | Description |
---|---|
Behavior |
The behavior scope ( |
Execution |
The execution scope ( |
Validation |
The validation scope ( |
The following examples compare MUnit tests in 1.x to 2.x.
<munit:test name="sampleTest" description="Test">
<munit:behavior>
<munit-tools:mock-when processor="mule:set-payload">
<munit-tools:then-return>
<munit-tools:payload value="#['Sample']" />
</munit-tools:then-return>
</munit-tools:mock-when>
</munit:behavior>
<munit:execution>
<flow-ref name="sampleFlow"/>
</munit:execution>
<munit:validation>
<munit-tools:assert-that expression="#[payload]" is="#[MunitTools::equalTo('SampleString')]"/>
</munit:validation>
</munit:test>