Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

To Operate the MUnit Maven Plugin

This section is dedicated to showing you how to run your tests using the plugin.

To Run MUnit Tests for a Mule Application (MUnit Maven Plugin)

Running MUnit tests in a Single Resource Mule project.
mvn clean test

If your application is a multi-module application:

  1. Make sure your mule-domain dependency is marked as provided in your application’s POM file.

    Add your Mule Domain as a Dependency in your Mule Application POM File.
    
                
             
    1
    2
    3
    4
    5
    6
    7
    
    <dependency>
        <groupId>org.mule.app</groupId>
        <artifactId>domain-project</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <classifier>mule-domain</classifier>
        <scope>provided</scope>
    </dependency>
  2. Run mvn install, instead of mvn test.

    mvn clean install

To Run a Specific MUnit Test Suite (MUnit Maven Plugin)

You can instruct MUnit Maven Plugin to run only tests that belong to a specific test suite.

To do this, we use the property munit.test.

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

If your application is a multi-module application:

  1. Make sure your mule-domain dependency is marked as provided in your application’s POM file.

    Add your Mule Domain as a Dependency in your Mule Application POM File.
    
                
             
    1
    2
    3
    4
    5
    6
    7
    
    <dependency>
        <groupId>org.mule.app</groupId>
        <artifactId>domain-project</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <classifier>mule-domain</classifier>
        <scope>provided</scope>
    </dependency>
  2. Run mvn install, instead of mvn test.

    mvn clean install -Dmunit.test=<regex-test-suite>

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.
This path is relative to src/test/munit.

The following is a valid example:

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

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

To Run Specific MUnit Tests (MUnit Maven Plugin)

In the same way that you instruct MUnit to run one test suite, you can also tell it to run a specific test inside that test suite. To do so, we again make use of the property munit.test, with one addition:

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

If your application is a multi-module application:

  1. Make sure your mule-domain dependency is marked as provided in your application’s POM file.

    Add your Mule Domain as a Dependency in your Mule Application POM File.
    
                
             
    1
    2
    3
    4
    5
    6
    7
    
    <dependency>
        <groupId>org.mule.app</groupId>
        <artifactId>domain-project</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <classifier>mule-domain</classifier>
        <scope>provided</scope>
    </dependency>
  2. Run mvn install, instead of mvn test.

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

The addition is the special character #. To the right of it, you should type the test name. It also accepts regular expressions. The expression is applied to the attribute name of the MUnit Test.

The following is a valid example:

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

The tests inside the MUnit Test Suite that don’t match the regular expression is flagged as ignored.

To Run Tests Using a Specific Tag (MUnit Maven Plugin)

You can choose to run only the tests that you grouped under one specific tag.

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

If your application is a multi-module application:

  1. Make sure your mule-domain dependency is marked as provided in your application’s POM file.

    Add your Mule Domain as a Dependency in your Mule Application POM File.
    
                
             
    1
    2
    3
    4
    5
    6
    7
    
    <dependency>
        <groupId>org.mule.app</groupId>
        <artifactId>domain-project</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <classifier>mule-domain</classifier>
        <scope>provided</scope>
    </dependency>
  2. Run mvn install, instead of mvn test.

    mvn clean install -Dmunit.tags=<munit-tag>

To Skip All Tests (MUnit Maven Plugin)

When building your application, you may want to prevent a test from running. MUnit leverages the same mechanism as Maven, so if you wish to skip tests, you can make use of the parameter skipTests.

Skipping Tests example
mvn clean package -DskipTests

If your application is a multi-module application:

  1. Make sure your mule-domain dependency is marked as provided in your application’s POM file.

    Add your Mule Domain as a Dependency in your Mule Application POM File.
    
                
             
    1
    2
    3
    4
    5
    6
    7
    
    <dependency>
        <groupId>org.mule.app</groupId>
        <artifactId>domain-project</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <classifier>mule-domain</classifier>
        <scope>provided</scope>
    </dependency>
  2. Run mvn install, instead of mvn test.

    mvn clean install -DskipTests