SlideShare a Scribd company logo
1 of 24
03rd June 2023
Calicut MuleSoft Meetup Group
#9 MUnit in Mule 4
Safe Harbour Statement
● Both the speaker and the host are organizing this meet-up in individual capacity only. We are
not representing our companies here.
● This presentation is strictly for learning purposes only. Organizer/Presenter do not hold any
responsibility that same solution will work for your business requirements.
● This presentation is not meant for any promotional activities.
2
A recording of this meetup will be uploaded to events page within 24 hours.
Questions can be submitted/asked at any time in the Chat/Questions & Answers Tab.
Make it more Interactive!!!
Give us feedback! Rate this meetup session by filling feedback form at the end of the day.
We Love Feedbacks!!! Its Bread & Butter for Meetup.
Housekeeping
3
Organizers
Fathima Farzana
NJC Labs
MuleSoft / Integration Developer
John Mathew Philip
NJC Labs
MuleSoft / Integration Developer
Anoop Ramachandran
NJC Labs
Technical Instructor / Integration Architect
https://www.linkedin.com/feed/update/urn:li:activity:7069907733281406977/
✔ MuleSoft Ambassador
✔ MuleSoft Meetup Speaker
✔ Guwahati & Lucknow Meetup Leader
✔ Certified MuleSoft Developer & Architect
✔ Total 8 years of experience (6 in MuleSoft)
✔ Working as Associate Solution Architect at Apisero Inc.
Abhishek Bathwal
Apisero Inc
Associate Solution Architect
● About the Speaker
Introduction
linkedin.com/in/abhishek-bathwal-
49360694
youtube.com/@abhishekbathwal1805
youtube.com/@developersguide5562 6
7
Agenda
Introduction To
Munit
Different
Approach of
Writing Munit
Limitations of
Test Recorder
Munit Tools and
Components
Executing Munit
Suits
Munit Coverage
Live
Demonstration
What is Munit?
9
MUnit is Anypoint Platform’s dedicated unit testing tool specifically designed for Mule applications. It
runs inside a Mule runtime, manually in Anypoint Studio, and automatically as part of the Maven-based
CI/CD build process. MUnit is designed to create structural test cases as Mule flows. That means you
can use components on top of MUnit and MUnit tool modules.
What is Munit?
10
Different Approach of Writing Munit
● Munit Test Recorder
● Manually
11
Limitations with Test Recorder
The test recorder is limited in the following ways when you create MUnit tests:
● You cannot create tests for flows with Mule errors raised inside the flow or already
existing in the incoming event, not even if they are handled by an on error continue error
handler.
● A recorded flow execution ends successfully, but the result does not reach its
destination because the application is killed.
● Your validations fail every time your test runs if you configure Spy or Assert processors
to assert values for random data, time-dependent information (such as timestamps), or
values resulting from parallel processes, because those values change in every
execution.
● Mocking values resulting from parallel processes causes a mixture of real and mocked
data that compromises the execution of the processors that follow in your test.
● Although the recorder supports data iteration in the flow, such as recursivity or loops, it
does not support cases in which the structure of the data being tested changes inside
the iteration.
● The recorder does not support mocking a message before or inside a Foreach
12
● Test
● Mock When
● Set Event
● Asset That
● Assert Equal
● Asset Expression
● Verify Call
● Spy
Munit Tools and Components
13
Executing Munit Suite
● From Studio
● From cmd (mvn clean test)
14
Munit Coverage
The MUnit Coverage feature provides a measurement of how much of a Mule application has been
executed by a set of MUnit tests by counting the amount of event processors executed.This allows
you to obtain a quality standard for your application, and provides metrics for:
● Application overall coverage: An average of the items below.
● Resource coverage: Refers to each Mule configuration file under src/main/mule.
● Flow coverage: Refers to any of the following components: Flows, Sub-flows, and Batch jobs.
15
● <ignoreFlows>
<ignoreFlow>FlowName</ignoreFlow>
</ignoreFlows>
● <ignoreFiles>
<ignoreFile>FileNamet.xml</ignoreFile>
</ignoreFiles>
Ignoring Files or Flow
Munit for Batch
Processing
Batch Processing
Mule batch processing components are designed for reliable, asynchronous processing of larger-than-
memory data sets. The components are the Batch Job, Batch Step, and Batch Aggregator. The Batch
Job component automatically splits source data and stores it into persistent queues, which makes it
possible to process large data sets while providing reliability. In the event that the application is re-
deployed or Mule crashes, the job execution is able to resume at the point it stopped.
17
Phases:
● Load and Dispatch
● Process
● On Complete
MUnit for Batch
18
Demo
20
● https://docs.mulesoft.com/mule-runtime/3.6/munit
● https://docs.mulesoft.com/munit/2.3/test-recorder
● https://blogs.mulesoft.com/dev-guides/how-to-tutorials/munit-testing-strategies/
● https://dzone.com/articles/mock-apikitrouter-and-write-munit-test-cases-for-d
● https://youtu.be/iLTqZ_ZcdEs
● https://docs.mulesoft.com/mule-runtime/4.4/batch-processing-concept
● https://javastreets.com/blog/2017/9/mule-batch-processing-part1-introduction.html
● https://billennium.com/blog/munit-for-batch-module-in-mule-4/
Reference
Q&A
Take a stand !
22
●Nominate yourself for the next meetup speaker and suggest a topic as well.
23
● Share:
○ Tweet using the hashtag #MuleSoftMeetups
○ Invite your network to join: https://meetups.mulesoft.com/calicut/
● Feedback:
○ Fill out the survey feedback and suggest topics for upcoming events
○ Contact MuleSoft at meetups@mulesoft.com for ways to improve the program
What’s next?
Thank You

More Related Content

Similar to MUnit testing strategies for Mule applications

MuleSoft Meetup | Reading Meetup Group | Hosted by Integral Zone
MuleSoft Meetup | Reading Meetup Group | Hosted by Integral ZoneMuleSoft Meetup | Reading Meetup Group | Hosted by Integral Zone
MuleSoft Meetup | Reading Meetup Group | Hosted by Integral ZoneIntegralZone
 
MuleSoft Kochi Meetup #5– Handling Mule Exceptions
MuleSoft Kochi Meetup #5– Handling Mule ExceptionsMuleSoft Kochi Meetup #5– Handling Mule Exceptions
MuleSoft Kochi Meetup #5– Handling Mule Exceptionssumitahuja94
 
Testing strategies and best practices using MUnit
Testing strategies and best practices using MUnitTesting strategies and best practices using MUnit
Testing strategies and best practices using MUnitJimmy Attia
 
Princeton-NJ-Meetup-Troubleshooting-with-AnyPoint-Monitoring
Princeton-NJ-Meetup-Troubleshooting-with-AnyPoint-MonitoringPrinceton-NJ-Meetup-Troubleshooting-with-AnyPoint-Monitoring
Princeton-NJ-Meetup-Troubleshooting-with-AnyPoint-MonitoringSravan Lingam
 
Vancouver mulesoft meetup_23-july
Vancouver mulesoft meetup_23-julyVancouver mulesoft meetup_23-july
Vancouver mulesoft meetup_23-julyVikalp Bhalia
 
Toronto Virtual Meetup #12 - Testing Strategies and MUnit Test Recorder
Toronto Virtual Meetup #12 - Testing Strategies and MUnit Test RecorderToronto Virtual Meetup #12 - Testing Strategies and MUnit Test Recorder
Toronto Virtual Meetup #12 - Testing Strategies and MUnit Test RecorderAlexandra N. Martinez
 
Mule soft meetup_th_no1
Mule soft meetup_th_no1Mule soft meetup_th_no1
Mule soft meetup_th_no1WendyTey4
 
Mule Testing in Mulesfoft 4.X
Mule Testing in Mulesfoft 4.XMule Testing in Mulesfoft 4.X
Mule Testing in Mulesfoft 4.XAmit Singh
 
MuleSoft Surat Meetup#47 - Error Handling With MuleSoft
MuleSoft Surat Meetup#47 - Error Handling With MuleSoftMuleSoft Surat Meetup#47 - Error Handling With MuleSoft
MuleSoft Surat Meetup#47 - Error Handling With MuleSoftJitendra Bafna
 
Mule soft meetup_tw_no1_june17
Mule soft meetup_tw_no1_june17Mule soft meetup_tw_no1_june17
Mule soft meetup_tw_no1_june17WendyTey4
 
MuleSoft Surat Virtual Meetup#37 - Anypoint Monitoring On Premise
MuleSoft Surat Virtual Meetup#37 - Anypoint Monitoring On PremiseMuleSoft Surat Virtual Meetup#37 - Anypoint Monitoring On Premise
MuleSoft Surat Virtual Meetup#37 - Anypoint Monitoring On PremiseJitendra Bafna
 
MuleSoft Surat Meetup#40 - Watermarking Concept and Fragments in MuleSoft
MuleSoft Surat Meetup#40 - Watermarking Concept and Fragments in MuleSoftMuleSoft Surat Meetup#40 - Watermarking Concept and Fragments in MuleSoft
MuleSoft Surat Meetup#40 - Watermarking Concept and Fragments in MuleSoftJitendra Bafna
 
27th Hyderabad MuleSoft Meetup
27th Hyderabad MuleSoft Meetup27th Hyderabad MuleSoft Meetup
27th Hyderabad MuleSoft MeetupMuleSoft Meetups
 
MuleSoft Singapore Meetup May 2020
MuleSoft Singapore Meetup May 2020MuleSoft Singapore Meetup May 2020
MuleSoft Singapore Meetup May 2020Julian Douch
 
Sydney mule soft meetup 30 april 2020
Sydney mule soft meetup   30 april 2020Sydney mule soft meetup   30 april 2020
Sydney mule soft meetup 30 april 2020Royston Lobo
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Melbourne Virtual MuleSoft Meetup October 2021
Melbourne Virtual MuleSoft Meetup October 2021Melbourne Virtual MuleSoft Meetup October 2021
Melbourne Virtual MuleSoft Meetup October 2021Daniel Soffner
 
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63Angel Alberici
 

Similar to MUnit testing strategies for Mule applications (20)

MuleSoft Meetup | Reading Meetup Group | Hosted by Integral Zone
MuleSoft Meetup | Reading Meetup Group | Hosted by Integral ZoneMuleSoft Meetup | Reading Meetup Group | Hosted by Integral Zone
MuleSoft Meetup | Reading Meetup Group | Hosted by Integral Zone
 
MuleSoft Kochi Meetup #5– Handling Mule Exceptions
MuleSoft Kochi Meetup #5– Handling Mule ExceptionsMuleSoft Kochi Meetup #5– Handling Mule Exceptions
MuleSoft Kochi Meetup #5– Handling Mule Exceptions
 
Testing strategies and best practices using MUnit
Testing strategies and best practices using MUnitTesting strategies and best practices using MUnit
Testing strategies and best practices using MUnit
 
Princeton-NJ-Meetup-Troubleshooting-with-AnyPoint-Monitoring
Princeton-NJ-Meetup-Troubleshooting-with-AnyPoint-MonitoringPrinceton-NJ-Meetup-Troubleshooting-with-AnyPoint-Monitoring
Princeton-NJ-Meetup-Troubleshooting-with-AnyPoint-Monitoring
 
Vancouver mulesoft meetup_23-july
Vancouver mulesoft meetup_23-julyVancouver mulesoft meetup_23-july
Vancouver mulesoft meetup_23-july
 
Toronto Virtual Meetup #12 - Testing Strategies and MUnit Test Recorder
Toronto Virtual Meetup #12 - Testing Strategies and MUnit Test RecorderToronto Virtual Meetup #12 - Testing Strategies and MUnit Test Recorder
Toronto Virtual Meetup #12 - Testing Strategies and MUnit Test Recorder
 
Mule soft meetup_th_no1
Mule soft meetup_th_no1Mule soft meetup_th_no1
Mule soft meetup_th_no1
 
Mule Testing in Mulesfoft 4.X
Mule Testing in Mulesfoft 4.XMule Testing in Mulesfoft 4.X
Mule Testing in Mulesfoft 4.X
 
MuleSoft Surat Meetup#47 - Error Handling With MuleSoft
MuleSoft Surat Meetup#47 - Error Handling With MuleSoftMuleSoft Surat Meetup#47 - Error Handling With MuleSoft
MuleSoft Surat Meetup#47 - Error Handling With MuleSoft
 
Mule soft meetup_tw_no1_june17
Mule soft meetup_tw_no1_june17Mule soft meetup_tw_no1_june17
Mule soft meetup_tw_no1_june17
 
MuleSoft Surat Virtual Meetup#37 - Anypoint Monitoring On Premise
MuleSoft Surat Virtual Meetup#37 - Anypoint Monitoring On PremiseMuleSoft Surat Virtual Meetup#37 - Anypoint Monitoring On Premise
MuleSoft Surat Virtual Meetup#37 - Anypoint Monitoring On Premise
 
MuleSoft Surat Meetup#40 - Watermarking Concept and Fragments in MuleSoft
MuleSoft Surat Meetup#40 - Watermarking Concept and Fragments in MuleSoftMuleSoft Surat Meetup#40 - Watermarking Concept and Fragments in MuleSoft
MuleSoft Surat Meetup#40 - Watermarking Concept and Fragments in MuleSoft
 
27th Hyderabad MuleSoft Meetup
27th Hyderabad MuleSoft Meetup27th Hyderabad MuleSoft Meetup
27th Hyderabad MuleSoft Meetup
 
API LifeCycle Management
API LifeCycle ManagementAPI LifeCycle Management
API LifeCycle Management
 
Online Spanish meetup #1
Online Spanish meetup #1Online Spanish meetup #1
Online Spanish meetup #1
 
MuleSoft Singapore Meetup May 2020
MuleSoft Singapore Meetup May 2020MuleSoft Singapore Meetup May 2020
MuleSoft Singapore Meetup May 2020
 
Sydney mule soft meetup 30 april 2020
Sydney mule soft meetup   30 april 2020Sydney mule soft meetup   30 april 2020
Sydney mule soft meetup 30 april 2020
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Melbourne Virtual MuleSoft Meetup October 2021
Melbourne Virtual MuleSoft Meetup October 2021Melbourne Virtual MuleSoft Meetup October 2021
Melbourne Virtual MuleSoft Meetup October 2021
 
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63
 

Recently uploaded

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Recently uploaded (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

MUnit testing strategies for Mule applications

  • 1. 03rd June 2023 Calicut MuleSoft Meetup Group #9 MUnit in Mule 4
  • 2. Safe Harbour Statement ● Both the speaker and the host are organizing this meet-up in individual capacity only. We are not representing our companies here. ● This presentation is strictly for learning purposes only. Organizer/Presenter do not hold any responsibility that same solution will work for your business requirements. ● This presentation is not meant for any promotional activities. 2
  • 3. A recording of this meetup will be uploaded to events page within 24 hours. Questions can be submitted/asked at any time in the Chat/Questions & Answers Tab. Make it more Interactive!!! Give us feedback! Rate this meetup session by filling feedback form at the end of the day. We Love Feedbacks!!! Its Bread & Butter for Meetup. Housekeeping 3
  • 4. Organizers Fathima Farzana NJC Labs MuleSoft / Integration Developer John Mathew Philip NJC Labs MuleSoft / Integration Developer Anoop Ramachandran NJC Labs Technical Instructor / Integration Architect
  • 6. ✔ MuleSoft Ambassador ✔ MuleSoft Meetup Speaker ✔ Guwahati & Lucknow Meetup Leader ✔ Certified MuleSoft Developer & Architect ✔ Total 8 years of experience (6 in MuleSoft) ✔ Working as Associate Solution Architect at Apisero Inc. Abhishek Bathwal Apisero Inc Associate Solution Architect ● About the Speaker Introduction linkedin.com/in/abhishek-bathwal- 49360694 youtube.com/@abhishekbathwal1805 youtube.com/@developersguide5562 6
  • 7. 7 Agenda Introduction To Munit Different Approach of Writing Munit Limitations of Test Recorder Munit Tools and Components Executing Munit Suits Munit Coverage Live Demonstration
  • 9. 9 MUnit is Anypoint Platform’s dedicated unit testing tool specifically designed for Mule applications. It runs inside a Mule runtime, manually in Anypoint Studio, and automatically as part of the Maven-based CI/CD build process. MUnit is designed to create structural test cases as Mule flows. That means you can use components on top of MUnit and MUnit tool modules. What is Munit?
  • 10. 10 Different Approach of Writing Munit ● Munit Test Recorder ● Manually
  • 11. 11 Limitations with Test Recorder The test recorder is limited in the following ways when you create MUnit tests: ● You cannot create tests for flows with Mule errors raised inside the flow or already existing in the incoming event, not even if they are handled by an on error continue error handler. ● A recorded flow execution ends successfully, but the result does not reach its destination because the application is killed. ● Your validations fail every time your test runs if you configure Spy or Assert processors to assert values for random data, time-dependent information (such as timestamps), or values resulting from parallel processes, because those values change in every execution. ● Mocking values resulting from parallel processes causes a mixture of real and mocked data that compromises the execution of the processors that follow in your test. ● Although the recorder supports data iteration in the flow, such as recursivity or loops, it does not support cases in which the structure of the data being tested changes inside the iteration. ● The recorder does not support mocking a message before or inside a Foreach
  • 12. 12 ● Test ● Mock When ● Set Event ● Asset That ● Assert Equal ● Asset Expression ● Verify Call ● Spy Munit Tools and Components
  • 13. 13 Executing Munit Suite ● From Studio ● From cmd (mvn clean test)
  • 14. 14 Munit Coverage The MUnit Coverage feature provides a measurement of how much of a Mule application has been executed by a set of MUnit tests by counting the amount of event processors executed.This allows you to obtain a quality standard for your application, and provides metrics for: ● Application overall coverage: An average of the items below. ● Resource coverage: Refers to each Mule configuration file under src/main/mule. ● Flow coverage: Refers to any of the following components: Flows, Sub-flows, and Batch jobs.
  • 17. Batch Processing Mule batch processing components are designed for reliable, asynchronous processing of larger-than- memory data sets. The components are the Batch Job, Batch Step, and Batch Aggregator. The Batch Job component automatically splits source data and stores it into persistent queues, which makes it possible to process large data sets while providing reliability. In the event that the application is re- deployed or Mule crashes, the job execution is able to resume at the point it stopped. 17 Phases: ● Load and Dispatch ● Process ● On Complete
  • 19. Demo
  • 20. 20 ● https://docs.mulesoft.com/mule-runtime/3.6/munit ● https://docs.mulesoft.com/munit/2.3/test-recorder ● https://blogs.mulesoft.com/dev-guides/how-to-tutorials/munit-testing-strategies/ ● https://dzone.com/articles/mock-apikitrouter-and-write-munit-test-cases-for-d ● https://youtu.be/iLTqZ_ZcdEs ● https://docs.mulesoft.com/mule-runtime/4.4/batch-processing-concept ● https://javastreets.com/blog/2017/9/mule-batch-processing-part1-introduction.html ● https://billennium.com/blog/munit-for-batch-module-in-mule-4/ Reference
  • 21. Q&A
  • 22. Take a stand ! 22 ●Nominate yourself for the next meetup speaker and suggest a topic as well.
  • 23. 23 ● Share: ○ Tweet using the hashtag #MuleSoftMeetups ○ Invite your network to join: https://meetups.mulesoft.com/calicut/ ● Feedback: ○ Fill out the survey feedback and suggest topics for upcoming events ○ Contact MuleSoft at meetups@mulesoft.com for ways to improve the program What’s next?