Deep Dive into Munits in Mule 4 | MuleSoft Mysore Meetup #40
Event Link:-
https://meetups.mulesoft.com/events/details/mulesoft-mysore-presents-munits-in-mule-4-deep-dive/
Agenda
-Overview of Munits
-What is Munit and how does it help
-Overview of Code Coverage
-What is code coverage and its implications
-Parameterizing Munits
-Benefits and use cases
-Special cases of Munits
-Choice Router
-For Each Scope
-APIKIT
-Hands-On
-Each of the special cases mentioned
For Upcoming Meetups Join Mysore Meetup Group - https://meetups.mulesoft.com/mysore/
YouTube:- youtube.com/@mulesoftmysore
Mysore WhatsApp group:- https://chat.whatsapp.com/EhqtHtCC75vCAX7gaO842N
Speakers:-
Prithwish Karforma - https://www.linkedin.com/in/prithwish-karforma-b2727b1a1
Organizers:-
Shubham Chaurasia - https://www.linkedin.com/in/shubhamchaurasia1/
Giridhar Meka - https://www.linkedin.com/in/giridharmeka
Priya Shaw - https://www.linkedin.com/in/priya-shaw
4. • MuleSoft Developer at Hashedin by Deloitte.
• 5+ Years of Experience
• MuleSoft Certified Developer
Prithwish Karforma
Prithwish Karforma
Speaker
5. ● Overview of Munits
What is Munit and how does it help
● Overview of Code Coverage
What is code coverage and its implications
● Parameterizing Munits
Benefits and use cases
● Special cases of Munits
Choice Router
For Each Scope
APIKIT
● Hands-On
Each of the special cases mentioned
● Q&A
● Wrap-Up
Agenda
7. What is Munit
MUnit is a Mule application testing framework that allows us to easily build automated tests
for our integrations and APIs.
It provides a full suite of integration and unit test capabilities, and is fully integrated with
Maven for integration with continuous deployment environment.
Each test is divided in to 3 scopes –
Behaviour - The behaviour scope sets all the preconditions before executing the test logic.
Execution - The execution scope contains the testing logic which waits for all processes to finish before
executing the next scope.
Validation - The validation scope contains all the validations for the results of the execution scope.
10. What is Code Coverage
Code coverage is a white-box testing technique performed to verify the extent to which the code
has been executed.
Why perform Code Coverage?
Code coverage is primarily performed at the unit testing level. Unit tests are created by developers,
thus giving them the best vantage from which to decide what tests to include in unit testing.
A high percentage of code coverage results in lower chances of unidentified bugs. It is best to set
a minimum rate of code coverage that must be achieved before testing in production to reduce the
chances of bugs being detected later in development.
Code coverage answers several questions, such as:
● Are there enough tests in the unit test suite?
● Do more tests need to be added?
12. For complicated scenarios, it is often necessary to parameterize the event properties.
A parameterized test suite runs the same tests but with different inputs.
YAML-file based parameterising:
The test runs 4 times, each time with a different set of input-output pair, first with “aus”, then “nz”, then
“in” and finally “def” for default case.
We must save our parameterizations values in a YAML file in the /test/resources directory of our Mule
application project
Parameterizing Munits
13. Munit Configuration based:
In this case, the test runs twice with different input/output pairs each for choice and loop
scopes.
Parameterizing Munits