---
schema_version: "1"
id: c664052e687f080f2edcd7eea1ebcdcccfda182b1aadb2dd913c66b25ee72016
title: MUnit Maven Plugin
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/munit/latest/munit-maven-plugin.md
canonical_url: https://docs.mulesoft.com/munit/latest/munit-maven-plugin
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 9c76bb6e9e6377c10436e36be0f05832d0bf3fe6753bbb3bddf6c80d3c496f30
description: MuleSoft Documentation Site
release: "3.7"
latest: true
---
---
product: MUnit
version: 3.7
is-latest-version: true
keywords: munit, testing, unit testing
---

# MUnit Maven Plugin

> 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

The MUnit Maven Plugin runs MUnit tests as part of a continuous integration environment by
integrating with the Maven build lifecycle. These configurations apply only when running MUnit
through Maven, not from Anypoint Studio or Anypoint Code Builder.

## Set Up MUnit Maven Plugin

You must have the `<munit.version>` property in your pom.xml to set up MUnit Maven Plugin.

- Enable MUnit Maven Plugin in your `pom.xml` file:

  MUnit Maven Plugin

  ```xml
  <build>
    <plugins>
    ...

      <plugin>
        <groupId>com.mulesoft.munit.tools</groupId>
        <artifactId>munit-maven-plugin</artifactId>
        <version>${munit.version}</version>
        <executions>
          <execution>
            <id>test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

    ...
    </plugins>
  </build>
  ```

- Add MUnit dependencies to your `pom.xml` file:

  Dependencies

  ```xml
  <dependencies>
    ...
    <dependency>
      <groupId>com.mulesoft.munit</groupId>
      <artifactId>munit-runner</artifactId>
      <version>${munit.version}</version>
      <classifier>mule-plugin</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.mulesoft.munit</groupId>
      <artifactId>munit-tools</artifactId>
      <version>${munit.version}</version>
      <classifier>mule-plugin</classifier>
      <scope>test</scope>
    </dependency>
    ...
  </dependencies>
  ```

- Configure the repositories for the MUnit dependencies and plugin:

  Repositories

  ```xml
  <repositories>
    <repository>
      <id>mulesoft-releases</id>
        <name>MuleSoft Releases Repository</name>
        <url>https://repository.mulesoft.org/releases/</url>
        <layout>default</layout>
      </repository>
  </repositories>
  ```

  Plugin Repositories

  ```xml
  <pluginRepositories>
    <pluginRepository>
      <id>mulesoft-release</id>
      <name>mulesoft release repository</name>
      <layout>default</layout>
      <url>https://repository.mulesoft.org/releases/</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>
  ```

Most applications require Mule runtime engine Enterprise Edition to run MUnit tests. Maven downloads
the Enterprise runtime from a plugin repository.

1.  Configure your Enterprise repository credentials. See
    [Configure MuleSoft Enterprise Repository](https://docs.mulesoft.com/mule-runtime/latest/maven-reference#configure-mulesoft-enterprise-repository).

2.  Add the Enterprise repository as a plugin repository in the `pluginRepositories` section of your
    `pom.xml` file, together with the MuleSoft releases plugin repository. Set `id` to the same
    value as the `<id>` in the `<server>` entry of your `settings.xml` file:

    Enterprise Plugin Repository

    ```xml
    <pluginRepositories>
      ...
      <pluginRepository>
        <id>MuleRepository</id>
        <name>MuleRepository</name>
        <url>https://repository.mulesoft.org/nexus-ee/content/repositories/releases-ee/</url>
        <layout>default</layout>
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>
        </snapshots>
      </pluginRepository>
    </pluginRepositories>
    ```

> [!NOTE] MUnit has Surefire support built in. The reports output to `target/surefire-reports`.

### Handle Parent POM Files

You can declare the MUnit plugin in a parent `pom.xml` file and every child project under this file
can reference this definition.

To configure MUnit Maven Plugin in a parent-child POM relationship, include the MUnit plugin
declaration in the `<pluginManagement>` section of your parent `pom.xml` file.

In the following example, the `pirate-pom` project declares MUnit Maven Plugin in its plugin
management section. This section also defines a global configuration that each child under this
parent can reference, override, or ignore.

```xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.1.0</modelVersion>

    <groupId>org.pirate</groupId>
    <artifactId>pirate-pom</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <munit.version>2.3.0</munit.version>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.mulesoft.munit.tools</groupId>
                    <artifactId>munit-maven-plugin</artifactId>
                    <version>${munit.version}</version>
                    <executions>
                        <execution>
                            <id>test</id>
                            <phase>test</phase>
                            <goals>
                                <goal>test</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                      <coverage>
                          <runCoverage>true</runCoverage>
                          <failBuild>false</failBuild>
                          <requiredApplicationCoverage>0</requiredApplicationCoverage>
                          <requiredResourceCoverage>0</requiredResourceCoverage>
                          <requiredFlowCoverage>0</requiredFlowCoverage>
                          <formats>
                              <format>console</format>
                              <format>html</format>
                          </formats>
                      </coverage>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>
```

### Inherit a Parent Plugin

To inherit the MUnit plugin in your child `pom.xml` files, reference it in the `<plugin>` section of
each child POM file individually.

The following sample references the `pirate-pom` file as its parent. It declares the MUnit plugin in
a `<plugin>` section without specifying its `<version>` because the MUnit plugin configuration is
inherited from the `<pluginManagement>` section in the parent POM file:

POM child file sample

```xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <parent>
        <groupId>org.pirate</groupId>
        <artifactId>pirate-pom</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycompany</groupId>
    <artifactId>ninja</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>mule</packaging>
    <name>Mule ninja Application</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <app.runtime>4.1.4</app.runtime>
        <munit.version>2.3.0</munit.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>com.mulesoft.munit.tools</groupId>
                <artifactId>munit-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
```

### Ignore a Parent Plugin

Each child project under a parent `pom.xml` file can ignore the plugin referenced in the parent
plugin management section and not implement the plugin configuration declared there.

By not declaring the MUnit Plugin in your `<plugin>` section, you avoid inheriting the plugin
declared in **pirate-pom**:

Child POM file not inheriting the MUnit Maven Plugin

```xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <parent>
        <groupId>org.pirate</groupId>
        <artifactId>pirate-pom</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycompany</groupId>
    <artifactId>ninja</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>mule</packaging>
    <name>Mule ninja Application</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <mule.version>4.1.0</mule.version>
        <munit.version>2.3.0</munit.version>
    </properties>

    <build>
        <plugins>
            <plugin>
            </plugin>
        </plugins>
    </build>
</project>
```

### Override a Parent Plugin

When inheriting the plugin from a parent POM file, you can also override the parent configuration.
Overriding the plugin configuration from your parent POM file suppresses the original configuration
requiring you to declare all necessary configurations again.

The following example overrides the console coverage report from its parent POM file, replacing it
with the HTML report. Because the values from the other elements in the parent (`<failBuild>`,
`<requiredApplicationCoverage>`, `<requiredResourceCoverage>`, `<requiredFlowCoverage>`) aren’t
being referenced, this child file won’t inherit them and the default values are applied:

Coverage configuration in parent POM file

```xml
<coverage>
	<runCoverage>true</runCoverage>
	<failBuild>false</failBuild>
	<requiredApplicationCoverage>0</requiredApplicationCoverage>
	<requiredResourceCoverage>0</requiredResourceCoverage>
	<requiredFlowCoverage>0</requiredFlowCoverage>
	<formats>
		<format>console</format>
		<format>html</format>
	</formats>
</coverage>
```

POM child file overriding coverage report format

```xml
<plugin>
	<groupId>com.mulesoft.munit.tools</groupId>
	<artifactId>munit-maven-plugin</artifactId>
	<configuration>
		<coverage>
			<runCoverage>true</runCoverage>
			<formats>
				<format>html</format>
			</formats>
		</coverage>
	</configuration>
</plugin>
```

## Set Up Coverage

The following configurations only apply when you execute your MUnit tests using the Maven plugin.
They don’t apply when running tests from Studio. See
[Using Coverage in Maven](https://docs.mulesoft.com/munit/latest/coverage-maven-concept) for additional information.

Configure MUnit coverage reports in Maven by adding the munit-maven-plugin to your pom.xml and
enabling the coverage-report goal. Coverage reports are generated during the Maven site lifecycle
and are not available when running tests from Anypoint Code Builder or Anypoint Studio.

MUnit Coverage - Sample Maven configuration

```xml
<plugin>
    <groupId>com.mulesoft.munit.tools</groupId>
    <artifactId>munit-maven-plugin</artifactId>
    <version>${munit.version}</version>

    <executions>
        <execution>
            <id>test</id>
            <phase>test</phase>
            <goals>
                <goal>test</goal>
                <goal>coverage-report</goal>
            </goals>
        </execution>
    </executions>

    <configuration>
        <coverage>
            <runCoverage>true</runCoverage>
            <failBuild>false</failBuild>

            <requiredApplicationCoverage>75</requiredApplicationCoverage>
            <requiredResourceCoverage>50</requiredResourceCoverage>
            <requiredFlowCoverage>50</requiredFlowCoverage>

            <formats>
                <format>console</format>
                <format>html</format>
            </formats>
        </coverage>
    </configuration>
</plugin>
```

### Set Up a Minimum Coverage Level

One of the features of MUnit Coverage is to fail the build if a certain coverage level isn’t
reached.

MUnit Coverage handles three different levels:

- **Application**: The overall coverage of all your application.

- **Resource**: The coverage level of each Mule configuration file.

- **Flow**: The coverage of event processors in each flow.

To define the required coverage levels:

MUnit Coverage - Require Coverage

```xml
<coverage>
    <runCoverage>true</runCoverage>
    <failBuild>true</failBuild>

    <requiredApplicationCoverage>75</requiredApplicationCoverage> (1)
    <requiredResourceCoverage>50</requiredResourceCoverage>
    <requiredFlowCoverage>50</requiredFlowCoverage>
</coverage>
```

<table><tbody><tr><td><i data-value="1"></i><b>1</b></td><td>Each value represents a percentage.<br>If a percentage isn’t defined, it defaults to <strong>-1</strong>, which sets no requirements for said level so the build doesn’t fail due to low coverage.</td></tr></tbody></table>

If you define coverage levels but set the property `failBuild` to `false`, and then the levels
aren’t reached, a warning shows up in the MUnit Coverage summary:

```console
===============================================================================
MUnit Coverage Summary
===============================================================================
 * Resources: 2 - Flows: 3 - Processors: 4
 * Application Coverage: 75.00%

----------------------------- WARNING --------------------------------------
 * Flow: file2.xml -> file2Flow1 coverage is below defined limit. Required: 50.0% - Current: 00.00% (1)
====================================================================================
```

<table><tbody><tr><td><i data-value="1"></i><b>1</b></td><td>Warning detailing which coverage level isn’t met, and where it happens.</td></tr></tbody></table>

### Ignore a Flow or a File

You can also ignore a flow or a file. This way, the ignored resource:

- Does not count as coverage data.

- Does not affect the overall number of message processors.

- Does not cause a build to fail if the flow isn’t tested or if the flow doesn’t reach coverage
  metrics.

To ignore flows and files:

MUnit Coverage - Ignore flows and files

```xml
<coverage>
    <runCoverage>true</runCoverage>
    <failBuild>true</failBuild>

    <requiredApplicationCoverage>100</requiredApplicationCoverage>
    <requiredResourceCoverage>100</requiredResourceCoverage>
    <requiredFlowCoverage>100</requiredFlowCoverage>

    <ignoreFlows>
        <ignoreFlow>flow-1</ignoreFlow>
        <ignoreFlow>flow-2</ignoreFlow>
        ...
        <ignoreFlow>flow-n</ignoreFlow>
    </ignoreFlows>

    <ignoreFiles>
        <ignoreFile>mule-config-1.xml</ignoreFile>
        <ignoreFile>mule-config-2.xml</ignoreFile>
        ...
        <ignoreFile>mule-config-n.xml</ignoreFile>
    </ignoreFiles>
</coverage>
```

## Dynamic Ports

MUnit 2.2 and later introduce the `dynamic-port` global element, that allows you to define dynamic
ports at the MUnit suite level. Using this element instead of the plugin configuration described as
follows allows you to set the dynamic port both from Maven and Studio.  
See [Dynamic Ports](https://docs.mulesoft.com/munit/latest/dynamic-ports) to learn how to configure this element.

When testing a Mule application in a continuous integration (CI) environment, you might encounter
the following scenario:

Your application tries to open a specific port. The port is already in use. The application fails
with a port binding exception.

The MUnit Maven Plugin comes with a built-in feature to make your application use a free port.

MUnit Dynamic Ports instructs the MUnit Maven Plugin to look for unbound ports and reserve them
before running the tests over the Mule application. Each port selected is placed in a system
property under the name indicated in the configuration. The application can get the port number
through the use of placeholders afterward.

The plugin selects the ports from the range: `[40000,50000]`

> [!CAUTION] Dynamic Ports feature is only available as part of the MUnit Maven Plugin. This feature
> does not work when running tests in Anypoint Studio.

### Enable Dynamic Ports

To enable the feature, you must add the following code to the `configuration` section of the MUnit
Maven Plugin:

Dynamic Ports Configuration

```xml
<plugins>
  <plugin>
    <groupId>com.mulesoft.munit.tools</groupId>
    <artifactId>munit-maven-plugin</artifactId>
    <configuration>
    ...
    <dynamicPorts>
      <dynamicPort>a.dynamic.port</dynamicPort>
    </dynamicPorts>
    ...
    </configuration>
  </plugin>
</plugins>
```

If you have the `${http.port}` placeholder in your application, the configuration looks something
like:

Example

```xml
<dynamicPorts>
  <dynamicPort>http.port</dynamicPort>
</dynamicPorts>
```

### Prepare Your Application

A placeholder must parameterize the part of the application trying to make use of a port. For
example, to have your Mule application listening for HTTP traffic, provide the following
configuration:

HTTP Application

```xml
<http:listener-config name="HTTP_Listener_config">
  <http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>

<flow name="httpFlow">
  <http:listener path="/" config-ref="HTTP_Listener_config"/>
</flow>
```

The previous application always listens in port `8081`. To make it dynamic, change it to:

HTTP Application with dynamic port

```xml
<http:listener-config name="HTTP_Listener_config">
  <http:listener-connection host="0.0.0.0" port="${http.port}"/> (1)
</http:listener-config>

<flow name="httpFlow">
  <http:listener path="/" config-ref="HTTP_Listener_config"/>
</flow>
```

<table><tbody><tr><td><i data-value="1"></i><b>1</b></td><td>Notice the placeholder <code>${http.port}</code>.</td></tr></tbody></table>

With the application coded in this way and the configuration of Dynamic Ports in place, your
application starts each run listening on a different port.

## Enable Surefire Reports

MUnit has built-in support for Surefire. You mustn’t do additional configurations, and you can
disable it if not needed:

Disable Surefire reports

```none
<enableSurefireReports>false</enableSurefireReports>
```

You can find the reports under `${project.build.directory}/surefire-reports`.

By default, it’s set to `true`.

## Enable Sonar Reports

MUnit has built-in support for SonarQube, with a default setting of `true` for `enableSonarReports`.
No other configuration is required.

You can find the reports under `${project.build.directory}/sonar-reports`.

You can disable SONAR reports if not needed:

Disable Sonar reports

```none
<enableSonarReports>false</enableSonarReports>
```

You can find the reports under `${project.build.directory}/sonar-reports`.

By default, it’s set to `true`.

## Run Tests Using the Plugin

### Run MUnit Tests for a Mule Application

Run MUnit tests in a Single Resource Mule project.

```none
mvn clean test
```

### Run a Specific MUnit Test Suite

By using the property `munit.test`, you can instruct the MUnit Maven plugin to run certain tests
that belong to a specific test suite:

```maven
mvn clean test -Dmunit.test=<regex-test-suite>
```

This path is relative to `src/test/munit`.

The property `munit.test` accepts regular expressions. The expression is applied to the name of the
MUnit Test Suite file. The regular expression language is the Java implementation.

For example:

```console
mvn clean test -Dmunit.test=.*my-test.*
```

You can leverage this feature by adding naming conventions to your MUnit Test suites.

### Run Specific MUnit Tests

In the same way that you instruct MUnit to run one test suite, you can also configure it to run a
specific test in that test suite. You must use the property `munit.test` with the addition of the
special character `#` to append the test name:

```console
mvn clean test -Dmunit.test=<regex-test-suite>#<regex-test-name>
```

It also accepts regular expressions. The expression is applied to the attribute `name` of the MUnit
Test. For example:

```console
mvn clean test -Dmunit.test=.*my-test.*#.*test-scenario-1.*
```

MUnit flags the tests in the MUnit Test Suite that don’t match the regular expression as
**ignored**.

You can also configure this from the `pom.xml` configuration:

```xml
<plugins>
  <plugin>
      <groupId>com.mulesoft.munit.tools</groupId>
      <artifactId>munit-maven-plugin</artifactId>
      <configuration>
      ...
      <munitTest>example-MunitTest-suite.xml</munitTest>
      ...
    </configuration>
  </plugin>
</plugins>
```

### Run Tests Using a Specific Tag

You can run the tests that you grouped under one specific tag:

```console
mvn clean test -Dmunit.tags=<munit-tag>
```

You can also configure this from the `pom.xml` configuration:

```xml
<plugins>
  <plugin>
      <groupId>com.mulesoft.munit.tools</groupId>
      <artifactId>munit-maven-plugin</artifactId>
      <configuration>
      ...
      <munitTags>exampleMunitTag</munitTags>
      ...
    </configuration>
  </plugin>
</plugins>
```

You can specify more than one tag by separating them with a comma.

### Fail When No Tests Run

By default, MUnit fails the Maven build if it can’t find any MUnit test suites or if no tests run
from the discovered suites. This behavior helps ensure that applications in a CI pipeline include
and run MUnit tests.

To allow a build to succeed when no MUnit tests run, set `munitFailIfNoTests` to `false` in the
MUnit Maven Plugin configuration:

Allow builds with no MUnit tests

```xml
<plugins>
  <plugin>
      <groupId>com.mulesoft.munit.tools</groupId>
      <artifactId>munit-maven-plugin</artifactId>
      <configuration>
      ...
      <munitFailIfNoTests>false</munitFailIfNoTests>
      ...
    </configuration>
  </plugin>
</plugins>
```

You can also disable this behavior from the command line:

```console
mvn clean test -Dmunit.failIfNoTests=false
```

Use this setting only when no MUnit tests are expected to run. Maven’s `skipTests` parameter and
MUnit’s `skipMunitTests` parameter skip MUnit test execution and don’t run this validation.

### Skip All Tests

MUnit leverages the same mechanism as Maven. To skip tests, you must use the `skipTests` parameter:

Skip Tests example

```console
mvn clean package -DskipTests
```

You can also configure this from the `pom.xml` configuration:

```xml
<plugins>
  <plugin>
      <groupId>com.mulesoft.munit.tools</groupId>
      <artifactId>munit-maven-plugin</artifactId>
      <configuration>
      ...
      <skipMunitTests>true</skipMunitTests>
      ...
    </configuration>
  </plugin>
</plugins>
```

### Skip Tests After One Suite Fails

MUnit allows you to skip the rest of the tests if one test suite fails:

```xml
<plugins>
  <plugin>
      <groupId>com.mulesoft.munit.tools</groupId>
      <artifactId>munit-maven-plugin</artifactId>
      <configuration>
      ...
      <skipAfterFailure>true</skipAfterFailure>
      ...
    </configuration>
  </plugin>
</plugins>
```

If not specified, it’s default value is `false`.

## Specify the Runtime Product

You can specify the type of runtime in which the applications you test run. Accepted values are:

- `MULE` for the Mule Kernel (formerly called Mule Community Edition)

- `MULE_EE` for the Mule Enterprise Edition

```xml
<plugins>
  <plugin>
    <groupId>com.mulesoft.munit.tools</groupId>
    <artifactId>munit-maven-plugin</artifactId>
    <configuration>
      ...
      <runtimeProduct>MULE</runtimeProduct>
      ...
    </configuration>
  </plugin>
</plugins>
```

### Specify the Runtime Product Version

You can specify the runtime version in which the applications you test run.

```xml
<plugins>
  <plugin>
    <groupId>com.mulesoft.munit.tools</groupId>
    <artifactId>munit-maven-plugin</artifactId>
    <configuration>
      ...
      <munit.runtimeversion>4.2.2</munit.runtimeversion>
      ...
    </configuration>
  </plugin>
</plugins>
```

The `munit.runtimeversion` property replaces the deprecated `runtimeVersion` property. The
`runtimeVersion` property remains supported. If you use `runtimeVersion`, MUnit displays a warning
message that indicates the property is deprecated and that you must migrate to
`munit.runtimeversion`.

## Specify the JVM

You can specify the JVM (or the Java executable) in which the applications you test run. You must
populate the `munit.jvm` parameter with the path to the executable:

Specify the JVM

```console
mvn clean package -Dmunit.jvm=/path/to/jdk/bin/java
```

You can also configure this from the `pom.xml` configuration:

```xml
<plugins>
  <plugin>
    <groupId>com.mulesoft.munit.tools</groupId>
    <artifactId>munit-maven-plugin</artifactId>
    <configuration>
      ...
      <jvm>/path/to/jdk/bin/java</jvm>
      ...
    </configuration>
  </plugin>
</plugins>
```

### Additional Argument Lines

You can pass additional argument lines to the JVM. Specify each argument in a separate `argLine`:

Argument lines

```xml
<plugins>
  <plugin>
    <groupId>com.mulesoft.munit.tools</groupId>
    <artifactId>munit-maven-plugin</artifactId>
    <configuration>
      ...
      <argLines>
          <argLine>-XX:MaxPermSize=512m</argLine>
          <argLine>-Xmx1024m</argLine>
      </argLines>
      ...
    </configuration>
  </plugin>
</plugins>
```

### Environment Variables

To set additional environment variables during the test run, you can specify them with the
respective key and value:

Additional Environment Variables

```xml
<plugins>
  <plugin>
    <groupId>com.mulesoft.munit.tools</groupId>
    <artifactId>munit-maven-plugin</artifactId>
    <configuration>
      ...
      <environmentVariables>
        <MY_ENV>exampleValue</MY_ENV>
        <MY_OTHER_ENV>val2</MY_OTHER_ENV>
      </environmentVariables>
      ...
    </configuration>
  </plugin>
</plugins>
```

As shown in the previous example, you can use environment variables to replace placeholders such as
`${MY_ENV}`.

### System Properties Variables

If you must define specific system variables to run your MUnit test successfully:

Setting system property variables

```xml
<plugins>
  <plugin>
    <groupId>com.mulesoft.munit.tools</groupId>
    <artifactId>munit-maven-plugin</artifactId>
    <configuration>
      ...
      <systemPropertyVariables>
        <my.property.key>my.property.value</my.property.key>
      </systemPropertyVariables>
      ...
    </configuration>
  </plugin>
</plugins>
```

Depending on the execution context, the system property values can vary. When referencing these
properties, you must override their value to enforce test reproducibility.

You can do so by using the ­`-D` argument when running MUnit with Maven. Variables passed with the
`-D` argument take full priority over any other property. For example:

```none
-Dmy.property.key=my.property.another.value
```

## Redirect Test Output to File

When running several tests, the build output can get very complex to read. MUnit allows you to
redirect the output of each test suite to a file. This way, the test results remain in the build
output and you can check the respective file to check the standard output of each test suite.

You can find these files in the `testOutputDirectory` folder following the naming convention:
`munit.${suiteName}-output.txt`, where `suiteName` represents the name of the XML file relative to
the MUnit test folder.

The test output that doesn’t belong to a particular suite isn’t printed to keep the build output
clean. You can enable it by running Maven in debug mode.

To redirect the output of each test suite to a file:

Redirect test output to a file

```xml
<plugins>
  <plugin>
    <groupId>com.mulesoft.munit.tools</groupId>
    <artifactId>munit-maven-plugin</artifactId>
    <configuration>
      ...
      <redirectTestOutputToFile>true</redirectTestOutputToFile>
      ...
    </configuration>
  </plugin>
</plugins>
```

By default, it’s set to `false`.

### Test Output Directory

If you want to choose the location where the test creates the output files, the path specified can
be absolute or written as a Maven placeholder:

Test output directory with absolute path

```xml
<plugins>
  <plugin>
    <groupId>com.mulesoft.munit.tools</groupId>
    <artifactId>munit-maven-plugin</artifactId>
    <configuration>
      ...
      <testOutputDirectory>/my/absolute/path</testOutputDirectory>
      ...
    </configuration>
  </plugin>
</plugins>
```

Test output directory using Maven placeholders

```xml
<testOutputDirectory>${project.build.directory}/my/output/folder</testOutputDirectory>
```

By default, the files are created in `${project.build.directory}/munit-reports/output/`.

## MUnit Maven Plugin Configuration Reference

The MUnit Maven Plugin offers a set of optional configurable parameters.

<table><caption>Table 1. Maven Plugin Parameters</caption> <colgroup><col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><code>argLines</code></p></div></div></td><td><div><div><p>List</p></div></div></td><td><div><div><p>Additional JVM argument lines to set on the test run.</p></div></div></td></tr><tr><td><div><div><p><code>coverage</code></p></div></div></td><td><div><div><p>Configuration</p></div></div></td><td><div><div><p>Coverage configuration to set on the test run.</p></div></div></td></tr><tr><td><div><div><p><code>dynamicPorts</code></p></div></div></td><td><div><div><p>List</p></div></div></td><td><div><div><p>Dynamic ports to set on the test run.</p></div></div></td></tr><tr><td><div><div><p><code>enableSurefireReports</code></p></div></div></td><td><div><div><p>boolean</p></div></div></td><td><div><div><p>Set value to <code>true</code> to generate MUnit test results in the Surefire format.<br>Its default value is <code>true</code>.</p></div></div></td></tr><tr><td><div><div><p><code>munitTest</code></p></div></div></td><td><div><div><p>String</p></div></div></td><td><div><div><p>Name of the MUnit tests to run.</p></div></div></td></tr><tr><td><div><div><p><code>munitTags</code></p></div></div></td><td><div><div><p>String</p></div></div></td><td><div><div><p>Name of the MUnit tags. Tests tagged with these names run.</p></div></div></td></tr><tr><td><div><div><p><code>munitFailIfNoTests</code></p></div></div></td><td><div><div><p>boolean</p></div></div></td><td><div><div><p>Fails the Maven build if no MUnit test suites are found or no tests run from the discovered suites.<br>Its default value is <code>true</code>.</p></div></div></td></tr><tr><td><div><div><p><code>skipMunitTests</code></p></div></div></td><td><div><div><p>boolean</p></div></div></td><td><div><div><p>Setting this parameter to <code>true</code> skips all MUnit tests.<br>Its default value is <code>false</code>.</p></div></div></td></tr><tr><td><div><div><p><code>skipAfterFailure</code></p></div></div></td><td><div><div><p>boolean</p></div></div></td><td><div><div><p>Skip all tests if one fails.<br>Its default value is <code>false</code>.</p></div></div></td></tr><tr><td><div><div><p><code>munitTestsDirectory</code></p></div></div></td><td><div><div><p>File</p></div></div></td><td><div><div><p>Directory where the MUnit tests reside.<br>Its default value is <code>${project.build.directory}/test-mule/munit</code>.</p></div></div></td></tr><tr><td><div><div><p><code>munit.runtimeversion</code></p></div></div></td><td><div><div><p>String</p></div></div></td><td><div><div><p>Version of the Mule runtime<br>When you run your tests from Maven, this value comes from the <code>minMuleVersion</code> parameter in the <code>mule-artifact.json</code> file.<br>To modify the Mule runtime version used to run your MUnit tests, see <a href="https://docs.mulesoft.com/munit/latest/runtime-patching">Runtime Patching</a>.</p></div></div></td></tr><tr><td><div><div><p><code>runtimeVersion</code> (deprecated)</p></div></div></td><td><div><div><p>String</p></div></div></td><td><div><div><p>Deprecated alias for <code>munit.runtimeversion</code>.<br>This property remains supported for backward compatibility.<br>When you use this property, MUnit displays a warning message and instructs you to migrate to <code>munit.runtimeversion</code>.</p></div></div></td></tr><tr><td><div><div><p>runtimeProduct</p></div></div></td><td><div><div><p>String</p></div></div></td><td><div><div><p>Type of runtime. Expected values are:</p></div><div><ul><li><p><code>MULE</code> for the Mule Kernel (formerly called Mule Community Edition)</p></li><li><p><code>MULE_EE</code> for the Mule Enterprise Edition</p></li></ul></div><div><p>By default, this value comes from the <code>requiredProduct</code> parameter in the <code>mule-artifact.json</code> file.</p></div></div></td></tr><tr><td><div><div><p><code>jvm</code></p></div></div></td><td><div><div><p>String</p></div></div></td><td><div><div><p>Option to specify the JVM (or path to the Java executable) to use.</p></div><div><p>By default, the JVM is the same VM as the one used to run Maven.</p></div></div></td></tr><tr><td><div><div><p><code>environmentVariables</code></p></div></div></td><td><div><div><p>Map</p></div></div></td><td><div><div><p>Additional environment variables to set on the test run.</p></div></div></td></tr><tr><td><div><div><p><code>redirectTestOutputToFile</code></p></div></div></td><td><div><div><p>boolean</p></div></div></td><td><div><div><p>Setting this value to <code>true</code> redirects the MUnit tests standard output to a file.<br>Its default value is <code>false</code>.</p></div></div></td></tr><tr><td><div><div><p><code>systemPropertyVariables</code></p></div></div></td><td><div><div><p>Map</p></div></div></td><td><div><div><p>System properties set on the test run.</p></div></div></td></tr><tr><td><div><div><p><code>testOutputDirectory</code></p></div></div></td><td><div><div><p>File</p></div></div></td><td><div><div><p>Directory where the test outputs are written.<br>Its default value is <code>${project.build.directory}/munit-reports/output/</code>.</p></div></div></td></tr></tbody></table>
