In this Article we will see how to run single munit at a time through command line and from Anypoint studio.

Also we will see how to run MUnits using Tags from command line

Execute from Command Line

Using “mvn test” at the terminal will test all MUnit tests, but here we describe how to test only one MUnit file

Run the following command at the project root folder.


In the following example, the MUnit test file is called run-single-munit-test-suite.xml


mvn clean test -Dmunit.test=run-single-munit-test-suite.xml


Running Single MUnit test case

XML file contains several tests, you may add the test name like this:

mvn clean test -Dmunit.test=abc.xml#testName


mvn clean test -Dmunit.test=mvn clean test -Dmunit.test=run-single-munit-test-suite.xml#run-single-munit-test-suite-run-single-munitFlowTest
  
In this case, the “testName” is the name of the test to be executed.

Execute from AnypointStudio

Right click in Munit file –> Run MUnit suite
Run MUnit suite


Right click on test Name–> Run MUnit test
Run MUnit test

Running Munit using Tags CommandLine

Tags are important to categorize the MUnits that needs to be executed based on the requirement. It is more like developer friendly to execute the different test scenarios.

Munit Tags

mvn clean test -Dmunit.tags=flow

Above command will run all the munit tests tagged as name “flow

You can also use combination as below:

mvn clean test -Dmunit.test=run-single-munit-test-suite.xml -Dmunit.tags=flow

Please find sample Mule project in Github run-single-munit-Mule4

Happy learning 🙂


By Manish Kumar

I am having around 10 years of IT experience in Integration Architecture, Requirement gathering, Effort Estimation, Application Design\Development\Testing and Deployment including 5+ years of experience in MuleSoft ESB and Hybrid Integrations. DevOps and Cloud Integration is my area of interest.

Leave a Reply

Your email address will not be published. Required fields are marked *