Munit parameterization in Mule 4

 

In this tutorial we will demonstrate how can we use munit parameterization in mule 4 to run the single test case for multiple input and output

To demonstrate we will create a sample mule application and create a munit suite to test the mule application

Sample application:

 

Here we will create 2 scenarios when the age is greater than and equal to 18 and less than 18, we will create a single test case and configure the 2 different scenarios and run the munit

To create the test case-> right click on the flow and create a blank munit test case for this flow as shown below

 

 

Blank test case is created

 

Create the input and output(expected result) under test folder

 

 

 

 

To configure the scenarios, go to testcase-> go to global elements->click on edit->

Munit parameterization in Mule 4

 

Click on + sign to add the parameterization, provide the name as adult-flow, now select the flow and add the input and output

 

Munit parameterization in Mule 4

 

Now add another scenario as a new parameter and follow the same process

 

Munit parameterization in Mule 4

 

Now set the input as set payload as shown below in munit

Munit parameterization in Mule 4

 

Configure the assert as shown below

Munit parameterization in Mule 4

 

Now run the munit, you can see both the test cases are passed and both the condition are tested and coverage is 100 %.

Munit parameterization in Mule 4

 

Sample application: munit-parameterization

  
Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
 
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.


Share this:
Subscribe
Notify of
guest
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Mahesh
Mahesh
1 year ago

Hi Guys,

Nice tutorial!

Can you please upload the correct sample project as the one uploaded here is “microsoftteam_poc.zip”

swamy
swamy
1 year ago

can you please upload correct sample project

Aakanksha
Aakanksha
1 year ago

Hi Guys ,

Can you please help me to run munit test with runtime arguments