Author: Akshata Sawant
With the latest Release of Anypoint 7.5.1 in May 2020, we’ve now been gifted dynamic MUnits!
Unveiling MUnit 2.2.5 brings us some amazing new functionalities — MUnit Test Recorder being the prime among features.
Writing and executing MUnits has been a time-consuming process for all of us and we all have experienced it! So imagine the glee I’m experiencing while writing this blog as this feature is really a lifesaver (or timesaver :P)!
So basically we’ll see how we can generate our own MUnit test suites without actually writing them.
All we need to do is record the different scenarios using our beloved MUnit Test Recorder and there you go… you have your test scripts ready for execution
What you’ll need to get started:
- Anypoint Studio 7.5.*Â
- Munit version 2.2.5
- Postman or anything similar
So let’s begin 🙂
Step 1: Here you can see I’ve created very basic flow in Mule for demo purpose consisting of Listener, Transform Message, and a Logger!
All you need to do is click on the flow and right-click where you’ll get an option to record test for this flowÂ

Step 2: Once you’ve selected the option you’ll see a dialog box appearing on your screen stating it’s waiting for your input which means it’s waiting for you to trigger the flow so that it can capture your response and design Munits accordingly!

Step 3: I’ll trigger my application using postman!

Step 4: Once we’ve triggered the application the Munit test recorder will do the rest. Once the input has been recorded you’ll see the ‘Configure test’ option in the dialog box. Click on the button.

Step 5: Give your test suite an apt name!

Step 6: Once you click the next button you’ll see Munit test recorder has done the job for you.
You can see the attributes and payloads configured for you. Review them and click next

Step 7: Now you can see the test summary. Review it and click next!

Step 8: Tadaaaaaaaaaaaaaaa!!!! Your Munit test suite is ready and you can execute it!

Step 9: Execute the Munit test cases!

Step 10: You might get some port error! Ensure your port on which MUnit is running is accessible! Do make the required changes.. You may not get this error always

Step 11: Once completed you can generate test report, check your test results and coverage


Also, if you explore src/test/resources you’ll see how beautifully all the attributes, payload, and the variables have been set.

So be sure to give a try!