The base file in MUnit is the test suite file, an XML file located in the src/test/munit directory of your Mule application project. You can have as many MUnit test suite files as you need. Each MUnit test suite file is a collection of MUnit tests, and runs independently from other MUnit test suites.
An MUnit test suite can contain any combination of the following components:
-
Before/After Suites
-
Before/After Tests
-
MUnit tests
Each MUnit test suite is, behind the scenes, no different than a Mule configuration file. You can use several of the Mule top level elements such as flow, sub-flow, and scripts.
MUnit Configuration
The MUnit configuration element (munit:config) identifies a Mule configuration file as an MUnit suite file:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:munit="http://www.mulesoft.org/schema/mule/munit" xmlns:munit-tools="http://www.mulesoft.org/schema/mule/munit-tools"
xmlns="http://www.mulesoft.org/schema/mule/core"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/munit http://www.mulesoft.org/schema/mule/munit/current/mule-munit.xsd
http://www.mulesoft.org/schema/mule/munit-tools http://www.mulesoft.org/schema/mule/munit-tools/current/mule-munit-tools.xsd">
<munit:config name="An MUnit Suite" />
<!-- Tests -->
</mule>
Ignore a Suite
To ignore a whole suite from running, you can use the ignore attribute of the configuration:
<munit:config name="A MUnit Suite" ignore="true"/>
Minimum Mule Version
To specify that a suite should run if the Mule version that is equal or newer than a specific version, use the
minMuleVersion attribute of the configuration:
<munit:config name="A MUnit Suite" minMuleVersion="4.1.4"/>