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 use multiple MUnit test suite files. 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 similar to 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
Specify the minimum required Mule version to run a test suite by defining the minMuleVersion attribute of the configuration:
<munit:config name="A MUnit Suite" minMuleVersion="4.1.4"/>