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

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
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

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
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
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
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

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?