SlideShare uma empresa Scribd logo
1 de 29
Baixar para ler offline
Patna MuleSoft Meetup
Munit in Mule 4
AGENDA
● Introductions
● What Munit is and what you can do with Munit?
● Demo
● Q/A
Organizers
Om Prakash
Shyam Raj Prasad Amit Mohan
Speakers
Piyush Kumari
● Working as Senior Consultant at InvenioLSI.
● Approx 7 years of Total Experience.
● 6+ years experience in Mulesoft.
● Certified MuleSoft Developer.
Munit Introduction
What is Munit?
● Best Automated testing app in Anypoint Studio.
● Integrated with Anypoint studio, allow you to create, design and run Munits just like you
would mule application.
● Provides full coverage of code.
● Integrated with Maven and surefire with integrations with continuous deployment
environment.
With MUnits you can ?
Munits proves below features:
● Create you test cases by writing Mule code.
● Mock Processors(Http Requester, SAP Connector, ApiKit Router etc.)
● Spy on any processor
● Parameterized test cases based on types.
● Do end to end or particular at sub-flow level of testing.
● Check coverage in studio
● Get Coverage Reports.
Munits is divided into two main sub modules:
Munit operations:
● Before Suite: runs before executing Munit Test Suite
The MUnit Before Suite contains code that is meant to be executed before the whole suite.
The Before Suite has one execution rule: Run before all the tests, just once.
For example, suppose you have an MUnit Test Suite file with four tests. The code inside an
MUnit Before Suite runs just once, before your four tests
● After Suite:
The MUnit After Suite is a scope. It can contain code that is meant to be executed after the
whole suite. The After suite has one execution rule: Run after all the tests, just once.
For instance, let’s suppose you have an MUnit Test Suite File with four tests. The code
inside an MUnit After Suite, runs just once, after all your tests.
Munit operations:
● Before Test: runs BEFORE executing Munit Test.
The MUnit Before Test Scope contains code that is meant to be executed before each test. Each
Before Test scope follows the same execution rule: Run before each test.
● After Test: runs AFTER executing Munit Test.
The MUnit After Test Scope contains code that is meant to be executed after each test. Each After
Test scope follows the same execution rule: Run after each test.
● Test: adds a new test.
● Set Event: to set the initial payload to be supplied.
● Set null Payload: defines null payload for testing.
Munit Tools operations:
● Assert: validate mule event content.
○ Equals
○ Expression
○ That
● Mock When: mock event processor when it matches the
defined name and attributes.
● Spy: what happens when before/after event processor is
called.
● Verify Call: verify if the processor was called.
● Fail: allow you to fail you test case on purpose.
Various ways to create munit tests:
Method 1: File>New>MUnit Test
Various ways to create munit tests:
Method 2: Pallet Test Operation
Various ways to create munit tests:
Method 3: From Flow
Result: XML Creation and munit test suite
MUnit Tests Scope:
Behaviour Scope:
- Set all the conditions before executing test logic
- Mock and spy goes into this section
Execution scope:
- This is meant for testing the logic which will wait for all the processes to get completed before
executing the next scope.
- Runs flow through this section only.
Validation Scope:
- This is meant to have all the validations regarding the result of execution scope.
- Assert and verify comes here to validate and verify the flow.
MUnit Tests Scope:
- Scope looks like:
Set Event:
● Allows you to set payload,attributes and
variables.
● Normally defined at the beginning of munit test
to define the first message to set.
● You can define as many properties required for
you flow.
Assert That:
● Allows you to run assertions to validate the stats of event
content.
● Uses DataWeave function MUnit matchers to define the
conditions for any value in expression.
● Include the prefix MunitTool:: in the expression
○ notNullValue() checks that the expression is not null.
■ #[MunitTools::nullValue()]
Matchers:
● withMediaType(String)
#[MunitTools::withMediaType('text/xml')]
● containsString(String)
#[MunitTools::containsString('example')]
● greaterThan(Comparable)
#[MunitTools::greaterThan(|2017-08-09|)]"
● isEmpty()
#[MunitTools::isEmpty()]"
● Core Matchers: evaluate the core
value in the expression
● String Matchers: performs the
assertions on string expression.
● Comparable Matchers: compares the
expression against the specified value.
● Iterable and Map Matchers: when your
expression is an array or map data.
Examples:
Mock When:
Allows you to Mock an event processor when it matches the
defined name and attributes.
1. Pick Processor
2. Choose Target Processor
3. Select attributes(specific doc:name)
4. Click OK
Mock When:
Configure “Then Return “ Section:
● Then Return is defined to set the response which
we expect from the mocked processor.
● The response can be Payload, Variable, Attribute
or even an error.
1. Choose Type of response
2. Click Add Icon
3. Define Response
4. Click OK
SPY: Work as detective to check when happens
before and after the processor.
1. Pick Processor
2. Choose Target Processor
3. Select attributes(specific
doc:name)
4. Click OK
Verify Call: Allows you to verify is that particular processor
was called or not.
● Defining one test suite and then multiple test cases inside with multiple Munit:Test
Ways to write Munit Test Suite:
● Parametrizations:
Parameterization in munits allows you to run single test
with multiple cases(inputs and outputs).
PROS:
Developers can effectively cover
various logical flows without having
to write dedicated test flows for each
such logical flow
CONS:
Application will get deployed exactly
the number of parameterized test
cases written.
3(parametrization case) → 3 times
application will deploy.
● Basic Info:
1. To run single Munit from terminal:
i. mvn clean /munit test name/ -Dmunit.test=XYZ.xml#testName
2. Ignore particular flow or file from munit coverage:
<coverage>
<ignoreFlows>
<ignoreFlow>flow-name</ignoreFlow>
</ignoreFlows>
</coverage>
3. To run API skipping munits in local:
Maven clean package/mvn clean install -DskipTests
Demo
Networking time
Thank You

Mais conteúdo relacionado

Semelhante a Munit In Mule 4 | Patna MuleSoft Meetup #26

Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosFlutter Agency
 
Write unit test from scratch
Write unit test from scratchWrite unit test from scratch
Write unit test from scratchWen-Shih Chao
 
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoft
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoftMuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoft
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoftJitendra Bafna
 
Mule Meetup Hyderabad - Aug 2020
Mule Meetup Hyderabad - Aug 2020Mule Meetup Hyderabad - Aug 2020
Mule Meetup Hyderabad - Aug 2020Sravan Lingam
 
Unit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxUnit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxKnoldus Inc.
 
MuleSoft ESB Testing Mule Application using MUnit Test Suite
MuleSoft ESB Testing Mule Application using MUnit Test SuiteMuleSoft ESB Testing Mule Application using MUnit Test Suite
MuleSoft ESB Testing Mule Application using MUnit Test Suiteakashdprajapati
 
Munits in Mule 4 [Deep-Dive] | MuleSoft Mysore Meetup #40
Munits in Mule 4 [Deep-Dive] | MuleSoft Mysore Meetup #40Munits in Mule 4 [Deep-Dive] | MuleSoft Mysore Meetup #40
Munits in Mule 4 [Deep-Dive] | MuleSoft Mysore Meetup #40MysoreMuleSoftMeetup
 
MuleSoft MUnit Test Recorder Meetup
MuleSoft MUnit Test Recorder MeetupMuleSoft MUnit Test Recorder Meetup
MuleSoft MUnit Test Recorder MeetupAngel Alberici
 
Perfromane Test Tool jmeter
Perfromane Test Tool jmeterPerfromane Test Tool jmeter
Perfromane Test Tool jmeterNaga Mallala
 
Web Services and Introduction of SOAPUI
Web Services and Introduction of SOAPUIWeb Services and Introduction of SOAPUI
Web Services and Introduction of SOAPUIDinesh Kaushik
 
Beginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBeginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBaskar K
 
Android Test Driven Development & Android Unit Testing
Android Test Driven Development & Android Unit TestingAndroid Test Driven Development & Android Unit Testing
Android Test Driven Development & Android Unit Testingmahmoud ramadan
 
Unit testing using Munit Part 1
Unit testing using Munit Part 1Unit testing using Munit Part 1
Unit testing using Munit Part 1Anand kalla
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkOnkar Deshpande
 

Semelhante a Munit In Mule 4 | Patna MuleSoft Meetup #26 (20)

Unit testing in Unity
Unit testing in UnityUnit testing in Unity
Unit testing in Unity
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
 
Write unit test from scratch
Write unit test from scratchWrite unit test from scratch
Write unit test from scratch
 
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoft
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoftMuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoft
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoft
 
Mule Meetup Hyderabad - Aug 2020
Mule Meetup Hyderabad - Aug 2020Mule Meetup Hyderabad - Aug 2020
Mule Meetup Hyderabad - Aug 2020
 
Qtp basics
Qtp basicsQtp basics
Qtp basics
 
Unit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxUnit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptx
 
Testing in mule
Testing in muleTesting in mule
Testing in mule
 
Mule m unit
Mule m unitMule m unit
Mule m unit
 
MuleSoft ESB Testing Mule Application using MUnit Test Suite
MuleSoft ESB Testing Mule Application using MUnit Test SuiteMuleSoft ESB Testing Mule Application using MUnit Test Suite
MuleSoft ESB Testing Mule Application using MUnit Test Suite
 
Munits in Mule 4 [Deep-Dive] | MuleSoft Mysore Meetup #40
Munits in Mule 4 [Deep-Dive] | MuleSoft Mysore Meetup #40Munits in Mule 4 [Deep-Dive] | MuleSoft Mysore Meetup #40
Munits in Mule 4 [Deep-Dive] | MuleSoft Mysore Meetup #40
 
MuleSoft MUnit Test Recorder Meetup
MuleSoft MUnit Test Recorder MeetupMuleSoft MUnit Test Recorder Meetup
MuleSoft MUnit Test Recorder Meetup
 
Perfromane Test Tool jmeter
Perfromane Test Tool jmeterPerfromane Test Tool jmeter
Perfromane Test Tool jmeter
 
Web Services and Introduction of SOAPUI
Web Services and Introduction of SOAPUIWeb Services and Introduction of SOAPUI
Web Services and Introduction of SOAPUI
 
Beginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBeginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NET
 
Quality for developers
Quality for developersQuality for developers
Quality for developers
 
JMockit
JMockitJMockit
JMockit
 
Android Test Driven Development & Android Unit Testing
Android Test Driven Development & Android Unit TestingAndroid Test Driven Development & Android Unit Testing
Android Test Driven Development & Android Unit Testing
 
Unit testing using Munit Part 1
Unit testing using Munit Part 1Unit testing using Munit Part 1
Unit testing using Munit Part 1
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 

Mais de shyamraj55

Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftshyamraj55
 
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
 
ServiceNow Integration with MuleSoft.pptx
ServiceNow Integration with MuleSoft.pptxServiceNow Integration with MuleSoft.pptx
ServiceNow Integration with MuleSoft.pptxshyamraj55
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
How to release an Open Source Dataweave Library
How to release an Open Source Dataweave LibraryHow to release an Open Source Dataweave Library
How to release an Open Source Dataweave Libraryshyamraj55
 
Unleash the Solace Pub Sub connector | Banaglore MuleSoft Meetup #31
Unleash the Solace Pub Sub connector | Banaglore MuleSoft Meetup #31Unleash the Solace Pub Sub connector | Banaglore MuleSoft Meetup #31
Unleash the Solace Pub Sub connector | Banaglore MuleSoft Meetup #31shyamraj55
 
An overview of Anypoint API Community Manager
An overview of Anypoint API  Community ManagerAn overview of Anypoint API  Community Manager
An overview of Anypoint API Community Managershyamraj55
 
CryptoGraphy Module in Mulesoft
CryptoGraphy Module in MulesoftCryptoGraphy Module in Mulesoft
CryptoGraphy Module in Mulesoftshyamraj55
 
Simplifying Plugin & Dependency Management with POM, Parent-POM, and BOM
Simplifying Plugin & Dependency Management with POM, Parent-POM, and BOMSimplifying Plugin & Dependency Management with POM, Parent-POM, and BOM
Simplifying Plugin & Dependency Management with POM, Parent-POM, and BOMshyamraj55
 
ChatGPT and Slack Integration with MuleSoft
ChatGPT and Slack Integration with MuleSoftChatGPT and Slack Integration with MuleSoft
ChatGPT and Slack Integration with MuleSoftshyamraj55
 
Exploring Universal API Management And Flex Gateway
Exploring Universal API Management And Flex GatewayExploring Universal API Management And Flex Gateway
Exploring Universal API Management And Flex Gatewayshyamraj55
 
SNS - SQS, and the MuleSoft liaison.pdf
SNS - SQS, and the MuleSoft liaison.pdfSNS - SQS, and the MuleSoft liaison.pdf
SNS - SQS, and the MuleSoft liaison.pdfshyamraj55
 
CLI for DataWeave Scripts
CLI for DataWeave ScriptsCLI for DataWeave Scripts
CLI for DataWeave Scriptsshyamraj55
 
MuleSoft SAP Integration using IDocs
MuleSoft SAP Integration using IDocsMuleSoft SAP Integration using IDocs
MuleSoft SAP Integration using IDocsshyamraj55
 
MuleSoft Composer | Patna MuleSoft Meetup #14
MuleSoft Composer | Patna MuleSoft Meetup #14MuleSoft Composer | Patna MuleSoft Meetup #14
MuleSoft Composer | Patna MuleSoft Meetup #14shyamraj55
 
Salesforce, Slack, and Zendesk Integration with Mulesoft.pdf
Salesforce, Slack, and Zendesk Integration with Mulesoft.pdfSalesforce, Slack, and Zendesk Integration with Mulesoft.pdf
Salesforce, Slack, and Zendesk Integration with Mulesoft.pdfshyamraj55
 
Patna MuleSoft Meetup Anypoint Cloudhub 2.0
Patna MuleSoft Meetup Anypoint Cloudhub 2.0Patna MuleSoft Meetup Anypoint Cloudhub 2.0
Patna MuleSoft Meetup Anypoint Cloudhub 2.0shyamraj55
 

Mais de shyamraj55 (17)

Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
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...
 
ServiceNow Integration with MuleSoft.pptx
ServiceNow Integration with MuleSoft.pptxServiceNow Integration with MuleSoft.pptx
ServiceNow Integration with MuleSoft.pptx
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
How to release an Open Source Dataweave Library
How to release an Open Source Dataweave LibraryHow to release an Open Source Dataweave Library
How to release an Open Source Dataweave Library
 
Unleash the Solace Pub Sub connector | Banaglore MuleSoft Meetup #31
Unleash the Solace Pub Sub connector | Banaglore MuleSoft Meetup #31Unleash the Solace Pub Sub connector | Banaglore MuleSoft Meetup #31
Unleash the Solace Pub Sub connector | Banaglore MuleSoft Meetup #31
 
An overview of Anypoint API Community Manager
An overview of Anypoint API  Community ManagerAn overview of Anypoint API  Community Manager
An overview of Anypoint API Community Manager
 
CryptoGraphy Module in Mulesoft
CryptoGraphy Module in MulesoftCryptoGraphy Module in Mulesoft
CryptoGraphy Module in Mulesoft
 
Simplifying Plugin & Dependency Management with POM, Parent-POM, and BOM
Simplifying Plugin & Dependency Management with POM, Parent-POM, and BOMSimplifying Plugin & Dependency Management with POM, Parent-POM, and BOM
Simplifying Plugin & Dependency Management with POM, Parent-POM, and BOM
 
ChatGPT and Slack Integration with MuleSoft
ChatGPT and Slack Integration with MuleSoftChatGPT and Slack Integration with MuleSoft
ChatGPT and Slack Integration with MuleSoft
 
Exploring Universal API Management And Flex Gateway
Exploring Universal API Management And Flex GatewayExploring Universal API Management And Flex Gateway
Exploring Universal API Management And Flex Gateway
 
SNS - SQS, and the MuleSoft liaison.pdf
SNS - SQS, and the MuleSoft liaison.pdfSNS - SQS, and the MuleSoft liaison.pdf
SNS - SQS, and the MuleSoft liaison.pdf
 
CLI for DataWeave Scripts
CLI for DataWeave ScriptsCLI for DataWeave Scripts
CLI for DataWeave Scripts
 
MuleSoft SAP Integration using IDocs
MuleSoft SAP Integration using IDocsMuleSoft SAP Integration using IDocs
MuleSoft SAP Integration using IDocs
 
MuleSoft Composer | Patna MuleSoft Meetup #14
MuleSoft Composer | Patna MuleSoft Meetup #14MuleSoft Composer | Patna MuleSoft Meetup #14
MuleSoft Composer | Patna MuleSoft Meetup #14
 
Salesforce, Slack, and Zendesk Integration with Mulesoft.pdf
Salesforce, Slack, and Zendesk Integration with Mulesoft.pdfSalesforce, Slack, and Zendesk Integration with Mulesoft.pdf
Salesforce, Slack, and Zendesk Integration with Mulesoft.pdf
 
Patna MuleSoft Meetup Anypoint Cloudhub 2.0
Patna MuleSoft Meetup Anypoint Cloudhub 2.0Patna MuleSoft Meetup Anypoint Cloudhub 2.0
Patna MuleSoft Meetup Anypoint Cloudhub 2.0
 

Último

Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxMohamed Rizk Khodair
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the lifeNitinDeodare
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45MysoreMuleSoftMeetup
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...Nguyen Thanh Tu Collection
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Celine George
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Denish Jangid
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
How to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryHow to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryCeline George
 

Último (20)

Word Stress rules esl .pptx
Word Stress rules esl               .pptxWord Stress rules esl               .pptx
Word Stress rules esl .pptx
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the life
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
How to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryHow to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 Inventory
 

Munit In Mule 4 | Patna MuleSoft Meetup #26

  • 2. AGENDA ● Introductions ● What Munit is and what you can do with Munit? ● Demo ● Q/A
  • 4. Speakers Piyush Kumari ● Working as Senior Consultant at InvenioLSI. ● Approx 7 years of Total Experience. ● 6+ years experience in Mulesoft. ● Certified MuleSoft Developer.
  • 6. What is Munit? ● Best Automated testing app in Anypoint Studio. ● Integrated with Anypoint studio, allow you to create, design and run Munits just like you would mule application. ● Provides full coverage of code. ● Integrated with Maven and surefire with integrations with continuous deployment environment.
  • 7. With MUnits you can ? Munits proves below features: ● Create you test cases by writing Mule code. ● Mock Processors(Http Requester, SAP Connector, ApiKit Router etc.) ● Spy on any processor ● Parameterized test cases based on types. ● Do end to end or particular at sub-flow level of testing. ● Check coverage in studio ● Get Coverage Reports.
  • 8. Munits is divided into two main sub modules:
  • 9. Munit operations: ● Before Suite: runs before executing Munit Test Suite The MUnit Before Suite contains code that is meant to be executed before the whole suite. The Before Suite has one execution rule: Run before all the tests, just once. For example, suppose you have an MUnit Test Suite file with four tests. The code inside an MUnit Before Suite runs just once, before your four tests ● After Suite: The MUnit After Suite is a scope. It can contain code that is meant to be executed after the whole suite. The After suite has one execution rule: Run after all the tests, just once. For instance, let’s suppose you have an MUnit Test Suite File with four tests. The code inside an MUnit After Suite, runs just once, after all your tests.
  • 10. Munit operations: ● Before Test: runs BEFORE executing Munit Test. The MUnit Before Test Scope contains code that is meant to be executed before each test. Each Before Test scope follows the same execution rule: Run before each test. ● After Test: runs AFTER executing Munit Test. The MUnit After Test Scope contains code that is meant to be executed after each test. Each After Test scope follows the same execution rule: Run after each test. ● Test: adds a new test. ● Set Event: to set the initial payload to be supplied. ● Set null Payload: defines null payload for testing.
  • 11. Munit Tools operations: ● Assert: validate mule event content. ○ Equals ○ Expression ○ That ● Mock When: mock event processor when it matches the defined name and attributes. ● Spy: what happens when before/after event processor is called. ● Verify Call: verify if the processor was called. ● Fail: allow you to fail you test case on purpose.
  • 12. Various ways to create munit tests: Method 1: File>New>MUnit Test
  • 13. Various ways to create munit tests: Method 2: Pallet Test Operation
  • 14. Various ways to create munit tests: Method 3: From Flow Result: XML Creation and munit test suite
  • 15. MUnit Tests Scope: Behaviour Scope: - Set all the conditions before executing test logic - Mock and spy goes into this section Execution scope: - This is meant for testing the logic which will wait for all the processes to get completed before executing the next scope. - Runs flow through this section only. Validation Scope: - This is meant to have all the validations regarding the result of execution scope. - Assert and verify comes here to validate and verify the flow.
  • 16. MUnit Tests Scope: - Scope looks like:
  • 17. Set Event: ● Allows you to set payload,attributes and variables. ● Normally defined at the beginning of munit test to define the first message to set. ● You can define as many properties required for you flow.
  • 18. Assert That: ● Allows you to run assertions to validate the stats of event content. ● Uses DataWeave function MUnit matchers to define the conditions for any value in expression. ● Include the prefix MunitTool:: in the expression ○ notNullValue() checks that the expression is not null. ■ #[MunitTools::nullValue()]
  • 19. Matchers: ● withMediaType(String) #[MunitTools::withMediaType('text/xml')] ● containsString(String) #[MunitTools::containsString('example')] ● greaterThan(Comparable) #[MunitTools::greaterThan(|2017-08-09|)]" ● isEmpty() #[MunitTools::isEmpty()]" ● Core Matchers: evaluate the core value in the expression ● String Matchers: performs the assertions on string expression. ● Comparable Matchers: compares the expression against the specified value. ● Iterable and Map Matchers: when your expression is an array or map data. Examples:
  • 20. Mock When: Allows you to Mock an event processor when it matches the defined name and attributes. 1. Pick Processor 2. Choose Target Processor 3. Select attributes(specific doc:name) 4. Click OK
  • 21. Mock When: Configure “Then Return “ Section: ● Then Return is defined to set the response which we expect from the mocked processor. ● The response can be Payload, Variable, Attribute or even an error. 1. Choose Type of response 2. Click Add Icon 3. Define Response 4. Click OK
  • 22. SPY: Work as detective to check when happens before and after the processor. 1. Pick Processor 2. Choose Target Processor 3. Select attributes(specific doc:name) 4. Click OK
  • 23. Verify Call: Allows you to verify is that particular processor was called or not.
  • 24. ● Defining one test suite and then multiple test cases inside with multiple Munit:Test Ways to write Munit Test Suite:
  • 25. ● Parametrizations: Parameterization in munits allows you to run single test with multiple cases(inputs and outputs). PROS: Developers can effectively cover various logical flows without having to write dedicated test flows for each such logical flow CONS: Application will get deployed exactly the number of parameterized test cases written. 3(parametrization case) → 3 times application will deploy.
  • 26. ● Basic Info: 1. To run single Munit from terminal: i. mvn clean /munit test name/ -Dmunit.test=XYZ.xml#testName 2. Ignore particular flow or file from munit coverage: <coverage> <ignoreFlows> <ignoreFlow>flow-name</ignoreFlow> </ignoreFlows> </coverage> 3. To run API skipping munits in local: Maven clean package/mvn clean install -DskipTests
  • 27. Demo