SlideShare a Scribd company logo
All contents © MuleSoft Inc.
All contents © MuleSoft Inc.
All contents © MuleSoft Inc.
MuleSoft Community…
https://www.mulesoft.com/community
 MeetUps https://meetups.mulesoft.com/
 Connect https://connect.mulesoft.com/
 Documentation https://docs.mulesoft.com/general/
 Help Center https://help.mulesoft.com/s/
 Developer Site https://developer.mulesoft.com/
MuleSoft Community Links
All contents © MuleSoft Inc.
All contents © MuleSoft Inc.
MUnit is…
• Integrated with Anypoint Studio, allowing you to create, design and run MUnit
tests just like you would Mule applications.
• It provides a full suite of integration and unit test capabilities.
• Integrated with Maven and Surefire for integration with your continuous
deployment environment
What is Munit?
All contents © MuleSoft Inc.
Overview of MUnit
6
With MUnit you can:
• Create your test by writing Mule code
• Minimize manual testing
• Mock processors
• Spy any processor
• Verify processor calls
• Enable or ignore particular tests
• Check visual coverage in Studio
• Generate coverage reports
All contents © MuleSoft Inc.
MUnit Suite Sub Modules
7
• MUnit
MUnit is divided in two main sub modules:
• MUnit Tools
All contents © MuleSoft Inc.
MUnit Operations
MUnit Module
8
• Before Suite - runs BEFORE executing MUnit Test Suite
• Before Test - runs BEFORE executing MUnit Test
• After Test - runs AFTER executing MUnit Test
• After Suite - runs AFTER executing MUnit Test Suite
– Examples of use
• To alter and/or clear an Object Store
• Create/Initialize/Delete a Test Database or FTP Server
• Test – adds a new test
• Set Event – sets a mule event
• Set null payload – defines a null payload for testing
All contents © MuleSoft Inc.
MUnit Tools Operations
MUnit Tools Module
9
• Assert - validate the state of a Mule event’s content
– Equals
– Expression
– That
• Mock when - mock an event processor when it matches the
defined name and attributes
• Spy - what happens before/after an event processor is called
• Verify call - verify if a processor was called
• Fail - allows you to fail your test on purpose
• Run custom - custom assertion
All contents © MuleSoft Inc.
MUnit Database Server
MUnit Utils :: Database Server
10
To test code that connects with a database
server, you must install a database server in
your local environment to run the tests.
• Option 1: Have a dedicated external database
server for testing:
– Maven project would not be portable
– 3rd party would need to install the testing
database server to compile your project
• Option 2: Use MUnit to implement a database
server in your local environment
• Define the structure and content of your
database:
– SQL
– CSV
All contents © MuleSoft Inc.
MUnit Database Server
MUnit Utils :: Database Server
11
• allows you to execute instructions on the in-
memory databases
• add or remove registries before a test
• check if your data was stored correctly
PROCESSORS
• Execute - operation to insert new values to the
table
• Execute query- operation to retrieve all values
from the table (including the newly added ones)
• Validate that – validates results of a query
All contents © MuleSoft Inc.
MUnit FTP Server Operations
MUnit Utils :: FTP Server
12
• To test code that connects with an FTP server,
you must install an FTP server in your local
environment to run the tests.
• Option 1: Have a dedicated external FTP
server for testing:
– Maven project would not be portable
– 3rd party would need to install the testing FTP
server to compile your project
• Option 2: Use MUnit to implement a FTP
server in your local environment
All contents © MuleSoft Inc.
MUnit FTP Server Processors
MUnit Utils :: FTP Server
13
• Contains files
– attempts to validate the existence of a file in the
FTP server
– if file is not present, the processor fails causing the
test to fail
• Remove
– instructs the FTP server to remove a file from
storage
– This feature is of use when we are creating the
same file name several times.
• Example, we can make use of it in an after-test to
ensure that no name collisions cause the test to fail
All contents © MuleSoft Inc.
Create an MUnit Suite
14
Various ways to create MUnit Tests
Method 1: File>New>MUnit Test Method 2 – Pallet Test Operation
All contents © MuleSoft Inc.
Adding Tests Creates XML
15
Various ways to add MUnit Test RESULTS: XML Creation
Method 3- From Flow
All contents © MuleSoft Inc.
• Behavior Scope
– Meant to set all the preconditions before executing the test logic
– Mocks and spies go in this section
• Execution Scope
– Meant to have the testing logic which will wait for all processes
to finish before executing the next scope
– Run flows in this section
• Validation Scope
– Meant to have all the validations regarding the result of the
execution scope
– Assertions and verifications go here
MUnit Test Scopes
16
All contents © MuleSoft Inc.
Set Event
Set Event Processor
17
– Allows you to define a Mule Event.
– Normally used at the beginning of an
MUnit test, to define the first message
to send to the flow being tested.
– You can define as many properties per
each scope as you need for your test.
All contents © MuleSoft Inc.
Assert that
Assert That Event Processor
18
– Allows you to run assertions to validate the state
of an event’s content
– Can validate the event after the production code
runs
– Uses DataWeave functions called MUnit matchers
to define the assertion conditions for any value
in an expression
– Include the prefix MunitTool:: in the expression
• notNullValue() checks that the expression is not null.
As shown: #[MunitTools::notNullValue()]
All contents © MuleSoft Inc.
Matchers
Assert That MUnit Matchers
19
• Core Matchers - evaluate core values in
the expression
• String Matchers - perform assertions on
String expressions
• Comparable Matchers - compare the
expression against a specified value
• Iterable and Map Matchers - when your
expression is an array or a map of data
• withMediaType(String)
#[MunitTools::withMediaType('text/xml’)]
• containsString(String)
#[MunitTools::containsString('example’)]
• greaterThanOrEqualTo(Comparable)
#[MunitTools::greaterThanOrEqualTo(20)]
• isEmpty()
#[MunitTools::isEmpty()]
Examples
All contents © MuleSoft Inc.
Mock when
Mock When Event Processor
20
• Allows you to mock an event processor when it matches
the defined name and attributes
1) Pick processor
2) Select target processor
3) Select attributes
4) Click OK
All contents © MuleSoft Inc.
Configure “Then return” section
Mock When - Then Return
21
• Configure Then Return to define the type of
response the mocked processor should
return
• It could be a payload, a variable, attributes,
or even an error
1) Choose type of response
2) Click Add icon
3) Enter values
4) Click OK
All contents © MuleSoft Inc.
Spy
Spy Event Processor
22
– Allows you to spy what happens before and
after an event processor is called
– Tells MUnit to run a set of instructions before
and/or after the spied event
1) Pick processor
2) Select target processor
3) Select attributes
4) Click OK
All contents © MuleSoft Inc.
Verify Call
Verify Call Event Processor
23
– Allows you to verify if a processor was called
– you can validate if a specific processor has
been called:
• with a particular set of attributes
• a specific number of times
All contents © MuleSoft Inc.
Run MUnit Suite Select src/test/munit>Run As>Munit
Run MUnit Suite
24
• Right click Canvas
• Select Run MUnit suite
All contents © MuleSoft Inc.
Run MUnit Test
25
Run MUnit Test
• Right click In Test
• Select Run MUnit test
All contents © MuleSoft Inc.
DEMO #1 on MUnit Mock When - Then Return
All contents © MuleSoft Inc.
DEMO #1 Flow Details
27
All contents © MuleSoft Inc.
DEMO #1 MUnit Details
28
All contents © MuleSoft Inc.
DEMO #1 MUnit Test Results
29
All contents © MuleSoft Inc.
DEMO #1 MUnit Test Coverage Report
30
All contents © MuleSoft Inc.
DEMO #2 on MUnit Utils :: Database Server
All contents © MuleSoft Inc.
DEMO #2 MUnit Global Elements
32
All contents © MuleSoft Inc.
DEMO #2 Flow Details
33
All contents © MuleSoft Inc.
DEMO #2 MUnit Test Global Details
34
All contents © MuleSoft Inc.
DEMO #2 MUnit Test Coverage Report
35
All contents © MuleSoft Inc.
View test results and coverage
MUnit Coverage Report
36
1) All the tests for all test
suites
Green means successful
2) Errors: shows the
reason for test failure
3) Coverage: % of the
flow that were covered
4) Detailed coverage
report.
All contents © MuleSoft Inc.
Failures
Munit Failures
37
Munit Test Suite
FAIL
SUCCESS
Thank you

More Related Content

What's hot

Mule soft munit test
Mule soft munit testMule soft munit test
Mule soft munit test
Son Nguyen
 
Mulesoft KL Meetup 2
Mulesoft KL Meetup 2Mulesoft KL Meetup 2
Mulesoft KL Meetup 2
NitushreeJena
 
MuleSoft Online meetup - An expert's guide to Runtime fabric - August 2020
MuleSoft Online meetup -  An expert's guide to Runtime fabric - August 2020MuleSoft Online meetup -  An expert's guide to Runtime fabric - August 2020
MuleSoft Online meetup - An expert's guide to Runtime fabric - August 2020
Royston Lobo
 
Cracow MuleSoft Meetup #1
Cracow MuleSoft Meetup #1Cracow MuleSoft Meetup #1
Cracow MuleSoft Meetup #1
Wojtek Maciejczyk
 
Custom policies in mule 4 and a circuit breaker example
Custom policies in mule 4 and a circuit breaker exampleCustom policies in mule 4 and a circuit breaker example
Custom policies in mule 4 and a circuit breaker example
Royston Lobo
 
Maven in mulesoft
Maven in mulesoftMaven in mulesoft
Maven in mulesoft
venkata20k
 
Stockholm MuleSoft Meetup - Albin Kjellin, 15 Feb 2018
Stockholm MuleSoft Meetup - Albin Kjellin, 15 Feb 2018Stockholm MuleSoft Meetup - Albin Kjellin, 15 Feb 2018
Stockholm MuleSoft Meetup - Albin Kjellin, 15 Feb 2018
Ana Chiriţescu
 
Moscow MuleSoft meetup May 2021
Moscow MuleSoft meetup May 2021Moscow MuleSoft meetup May 2021
Moscow MuleSoft meetup May 2021
Leadex Systems
 
Baltimore july2021 final
Baltimore july2021 finalBaltimore july2021 final
Baltimore july2021 final
ManjuKumara GH
 
Mule: Munit domain support
Mule: Munit domain supportMule: Munit domain support
Mule: Munit domain support
Shanky Gupta
 
Mule esb munit
Mule esb munitMule esb munit
Mule esb munit
D.Rajesh Kumar
 
Aligning to AEMs Release Cycle
Aligning to AEMs Release CycleAligning to AEMs Release Cycle
Aligning to AEMs Release Cycle
Ashokkumar T A
 
MUnit - Introduction
MUnit - Introduction MUnit - Introduction
MUnit - Introduction
dasail
 
Continuous Integration
Continuous IntegrationContinuous Integration
Continuous Integration
Alea Soluciones, S.L.
 
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
Jitendra Bafna
 
Containerizing MuleSoft applications for hybrid deployment
Containerizing MuleSoft applications for hybrid deployment Containerizing MuleSoft applications for hybrid deployment
Containerizing MuleSoft applications for hybrid deployment
JuliaDemidova3
 
Maven and ANT
Maven and ANTMaven and ANT
Maven and ANT
Sun Technlogies
 
Mule esb domain
Mule esb domainMule esb domain
Mule esb domain
D.Rajesh Kumar
 
Nagpur Mulesoft Meetup on CICD using Jenkins
Nagpur Mulesoft Meetup on CICD using JenkinsNagpur Mulesoft Meetup on CICD using Jenkins
Nagpur Mulesoft Meetup on CICD using Jenkins
pqrs1234
 
How to Expand Anypoint Platform's Capabilities by Developing Custom Connectors
How to Expand Anypoint Platform's Capabilities by Developing Custom ConnectorsHow to Expand Anypoint Platform's Capabilities by Developing Custom Connectors
How to Expand Anypoint Platform's Capabilities by Developing Custom Connectors
AaronLieberman5
 

What's hot (20)

Mule soft munit test
Mule soft munit testMule soft munit test
Mule soft munit test
 
Mulesoft KL Meetup 2
Mulesoft KL Meetup 2Mulesoft KL Meetup 2
Mulesoft KL Meetup 2
 
MuleSoft Online meetup - An expert's guide to Runtime fabric - August 2020
MuleSoft Online meetup -  An expert's guide to Runtime fabric - August 2020MuleSoft Online meetup -  An expert's guide to Runtime fabric - August 2020
MuleSoft Online meetup - An expert's guide to Runtime fabric - August 2020
 
Cracow MuleSoft Meetup #1
Cracow MuleSoft Meetup #1Cracow MuleSoft Meetup #1
Cracow MuleSoft Meetup #1
 
Custom policies in mule 4 and a circuit breaker example
Custom policies in mule 4 and a circuit breaker exampleCustom policies in mule 4 and a circuit breaker example
Custom policies in mule 4 and a circuit breaker example
 
Maven in mulesoft
Maven in mulesoftMaven in mulesoft
Maven in mulesoft
 
Stockholm MuleSoft Meetup - Albin Kjellin, 15 Feb 2018
Stockholm MuleSoft Meetup - Albin Kjellin, 15 Feb 2018Stockholm MuleSoft Meetup - Albin Kjellin, 15 Feb 2018
Stockholm MuleSoft Meetup - Albin Kjellin, 15 Feb 2018
 
Moscow MuleSoft meetup May 2021
Moscow MuleSoft meetup May 2021Moscow MuleSoft meetup May 2021
Moscow MuleSoft meetup May 2021
 
Baltimore july2021 final
Baltimore july2021 finalBaltimore july2021 final
Baltimore july2021 final
 
Mule: Munit domain support
Mule: Munit domain supportMule: Munit domain support
Mule: Munit domain support
 
Mule esb munit
Mule esb munitMule esb munit
Mule esb munit
 
Aligning to AEMs Release Cycle
Aligning to AEMs Release CycleAligning to AEMs Release Cycle
Aligning to AEMs Release Cycle
 
MUnit - Introduction
MUnit - Introduction MUnit - Introduction
MUnit - Introduction
 
Continuous Integration
Continuous IntegrationContinuous Integration
Continuous Integration
 
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
 
Containerizing MuleSoft applications for hybrid deployment
Containerizing MuleSoft applications for hybrid deployment Containerizing MuleSoft applications for hybrid deployment
Containerizing MuleSoft applications for hybrid deployment
 
Maven and ANT
Maven and ANTMaven and ANT
Maven and ANT
 
Mule esb domain
Mule esb domainMule esb domain
Mule esb domain
 
Nagpur Mulesoft Meetup on CICD using Jenkins
Nagpur Mulesoft Meetup on CICD using JenkinsNagpur Mulesoft Meetup on CICD using Jenkins
Nagpur Mulesoft Meetup on CICD using Jenkins
 
How to Expand Anypoint Platform's Capabilities by Developing Custom Connectors
How to Expand Anypoint Platform's Capabilities by Developing Custom ConnectorsHow to Expand Anypoint Platform's Capabilities by Developing Custom Connectors
How to Expand Anypoint Platform's Capabilities by Developing Custom Connectors
 

Similar to MuleSoft Online MeetUp 03_11_2020

MuleSoft Meetup Charlotte 2019 - Dec 10
MuleSoft Meetup Charlotte  2019 - Dec 10MuleSoft Meetup Charlotte  2019 - Dec 10
MuleSoft Meetup Charlotte 2019 - Dec 10
Subhash Patel
 
Munit In Mule 4 | Patna MuleSoft Meetup #26
Munit In Mule 4 | Patna MuleSoft Meetup #26Munit In Mule 4 | Patna MuleSoft Meetup #26
Munit In Mule 4 | Patna MuleSoft Meetup #26
shyamraj55
 
Vancouver mulesoft meetup_23-july
Vancouver mulesoft meetup_23-julyVancouver mulesoft meetup_23-july
Vancouver mulesoft meetup_23-july
Vikalp Bhalia
 
Engineering Student MuleSoft Meetup#4 - API Testing With MuleSoft
Engineering Student MuleSoft Meetup#4 - API Testing With MuleSoftEngineering Student MuleSoft Meetup#4 - API Testing With MuleSoft
Engineering Student MuleSoft Meetup#4 - API Testing With MuleSoft
Jitendra Bafna
 
MuleSoft Meetup Charlotte 2 - 2019
MuleSoft Meetup Charlotte 2 - 2019MuleSoft Meetup Charlotte 2 - 2019
MuleSoft Meetup Charlotte 2 - 2019
Subhash Patel
 
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
akashdprajapati
 
Mule m unit
Mule m unitMule m unit
Mule m unit
VirtusaPolaris
 
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
Jitendra Bafna
 
Mulesoft meetup slides mumbai_20113019_exception_handling
Mulesoft meetup slides mumbai_20113019_exception_handlingMulesoft meetup slides mumbai_20113019_exception_handling
Mulesoft meetup slides mumbai_20113019_exception_handling
Manish Kumar Yadav
 
MuleSoft Clustring, Okta, CI/CD Integration with Jenkins
MuleSoft Clustring, Okta, CI/CD Integration with JenkinsMuleSoft Clustring, Okta, CI/CD Integration with Jenkins
MuleSoft Clustring, Okta, CI/CD Integration with Jenkins
Manish Kumar Yadav
 
Toronto mule soft meetup november 2021
Toronto mule soft meetup   november 2021Toronto mule soft meetup   november 2021
Toronto mule soft meetup november 2021
Anurag Dwivedi
 
Manila MuleSoft Meetup - August 2020
Manila MuleSoft Meetup - August 2020Manila MuleSoft Meetup - August 2020
Manila MuleSoft Meetup - August 2020
Ryan Anthony Andal
 
Mule soft indore meetup 2
Mule soft indore meetup 2Mule soft indore meetup 2
Mule soft indore meetup 2
Pradhan Yash Sharma
 
MuleSoft MUnit Test Recorder Meetup
MuleSoft MUnit Test Recorder MeetupMuleSoft MUnit Test Recorder Meetup
MuleSoft MUnit Test Recorder Meetup
Angel Alberici
 
Custom Connector development using Mule SDK
Custom Connector development using Mule SDKCustom Connector development using Mule SDK
Custom Connector development using Mule SDK
Navin Kare
 
Mocking with salesforce using Munit
Mocking with salesforce using MunitMocking with salesforce using Munit
Mocking with salesforce using Munit
Son Nguyen
 
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
Royston Lobo
 
Performance testing with Jmeter
Performance testing with JmeterPerformance testing with Jmeter
Performance testing with Jmeter
Prashanth Kumar
 
Mulesoft AnyyPoint Monitoring for Hybrid Deployment
Mulesoft AnyyPoint Monitoring for Hybrid DeploymentMulesoft AnyyPoint Monitoring for Hybrid Deployment
Mulesoft AnyyPoint Monitoring for Hybrid Deployment
pruthviraj krishnam
 
Warsaw MuleSoft Meetup #6 - CI/CD
Warsaw MuleSoft Meetup  #6 - CI/CDWarsaw MuleSoft Meetup  #6 - CI/CD
Warsaw MuleSoft Meetup #6 - CI/CD
Patryk Bandurski
 

Similar to MuleSoft Online MeetUp 03_11_2020 (20)

MuleSoft Meetup Charlotte 2019 - Dec 10
MuleSoft Meetup Charlotte  2019 - Dec 10MuleSoft Meetup Charlotte  2019 - Dec 10
MuleSoft Meetup Charlotte 2019 - Dec 10
 
Munit In Mule 4 | Patna MuleSoft Meetup #26
Munit In Mule 4 | Patna MuleSoft Meetup #26Munit In Mule 4 | Patna MuleSoft Meetup #26
Munit In Mule 4 | Patna MuleSoft Meetup #26
 
Vancouver mulesoft meetup_23-july
Vancouver mulesoft meetup_23-julyVancouver mulesoft meetup_23-july
Vancouver mulesoft meetup_23-july
 
Engineering Student MuleSoft Meetup#4 - API Testing With MuleSoft
Engineering Student MuleSoft Meetup#4 - API Testing With MuleSoftEngineering Student MuleSoft Meetup#4 - API Testing With MuleSoft
Engineering Student MuleSoft Meetup#4 - API Testing With MuleSoft
 
MuleSoft Meetup Charlotte 2 - 2019
MuleSoft Meetup Charlotte 2 - 2019MuleSoft Meetup Charlotte 2 - 2019
MuleSoft Meetup Charlotte 2 - 2019
 
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
 
Mule m unit
Mule m unitMule m unit
Mule m unit
 
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
 
Mulesoft meetup slides mumbai_20113019_exception_handling
Mulesoft meetup slides mumbai_20113019_exception_handlingMulesoft meetup slides mumbai_20113019_exception_handling
Mulesoft meetup slides mumbai_20113019_exception_handling
 
MuleSoft Clustring, Okta, CI/CD Integration with Jenkins
MuleSoft Clustring, Okta, CI/CD Integration with JenkinsMuleSoft Clustring, Okta, CI/CD Integration with Jenkins
MuleSoft Clustring, Okta, CI/CD Integration with Jenkins
 
Toronto mule soft meetup november 2021
Toronto mule soft meetup   november 2021Toronto mule soft meetup   november 2021
Toronto mule soft meetup november 2021
 
Manila MuleSoft Meetup - August 2020
Manila MuleSoft Meetup - August 2020Manila MuleSoft Meetup - August 2020
Manila MuleSoft Meetup - August 2020
 
Mule soft indore meetup 2
Mule soft indore meetup 2Mule soft indore meetup 2
Mule soft indore meetup 2
 
MuleSoft MUnit Test Recorder Meetup
MuleSoft MUnit Test Recorder MeetupMuleSoft MUnit Test Recorder Meetup
MuleSoft MUnit Test Recorder Meetup
 
Custom Connector development using Mule SDK
Custom Connector development using Mule SDKCustom Connector development using Mule SDK
Custom Connector development using Mule SDK
 
Mocking with salesforce using Munit
Mocking with salesforce using MunitMocking with salesforce using Munit
Mocking with salesforce using Munit
 
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
 
Performance testing with Jmeter
Performance testing with JmeterPerformance testing with Jmeter
Performance testing with Jmeter
 
Mulesoft AnyyPoint Monitoring for Hybrid Deployment
Mulesoft AnyyPoint Monitoring for Hybrid DeploymentMulesoft AnyyPoint Monitoring for Hybrid Deployment
Mulesoft AnyyPoint Monitoring for Hybrid Deployment
 
Warsaw MuleSoft Meetup #6 - CI/CD
Warsaw MuleSoft Meetup  #6 - CI/CDWarsaw MuleSoft Meetup  #6 - CI/CD
Warsaw MuleSoft Meetup #6 - CI/CD
 

Recently uploaded

Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
Sm321
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
AndrzejJarynowski
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
bopyb
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
nyfuhyz
 
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdfUdemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Fernanda Palhano
 
My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.
rwarrenll
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
74nqk8xf
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
manishkhaire30
 
A presentation that explain the Power BI Licensing
A presentation that explain the Power BI LicensingA presentation that explain the Power BI Licensing
A presentation that explain the Power BI Licensing
AlessioFois2
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
g4dpvqap0
 
State of Artificial intelligence Report 2023
State of Artificial intelligence Report 2023State of Artificial intelligence Report 2023
State of Artificial intelligence Report 2023
kuntobimo2016
 
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data LakeViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
Walaa Eldin Moustafa
 
University of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma TranscriptUniversity of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma Transcript
soxrziqu
 
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
74nqk8xf
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
Timothy Spann
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
roli9797
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
Roger Valdez
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
g4dpvqap0
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
vikram sood
 

Recently uploaded (20)

Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
 
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdfUdemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
 
My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
 
A presentation that explain the Power BI Licensing
A presentation that explain the Power BI LicensingA presentation that explain the Power BI Licensing
A presentation that explain the Power BI Licensing
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
 
State of Artificial intelligence Report 2023
State of Artificial intelligence Report 2023State of Artificial intelligence Report 2023
State of Artificial intelligence Report 2023
 
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data LakeViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
 
University of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma TranscriptUniversity of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma Transcript
 
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
 

MuleSoft Online MeetUp 03_11_2020

  • 1. All contents © MuleSoft Inc.
  • 2. All contents © MuleSoft Inc.
  • 3. All contents © MuleSoft Inc. MuleSoft Community… https://www.mulesoft.com/community  MeetUps https://meetups.mulesoft.com/  Connect https://connect.mulesoft.com/  Documentation https://docs.mulesoft.com/general/  Help Center https://help.mulesoft.com/s/  Developer Site https://developer.mulesoft.com/ MuleSoft Community Links
  • 4. All contents © MuleSoft Inc.
  • 5. All contents © MuleSoft Inc. MUnit is… • Integrated with Anypoint Studio, allowing you to create, design and run MUnit tests just like you would Mule applications. • It provides a full suite of integration and unit test capabilities. • Integrated with Maven and Surefire for integration with your continuous deployment environment What is Munit?
  • 6. All contents © MuleSoft Inc. Overview of MUnit 6 With MUnit you can: • Create your test by writing Mule code • Minimize manual testing • Mock processors • Spy any processor • Verify processor calls • Enable or ignore particular tests • Check visual coverage in Studio • Generate coverage reports
  • 7. All contents © MuleSoft Inc. MUnit Suite Sub Modules 7 • MUnit MUnit is divided in two main sub modules: • MUnit Tools
  • 8. All contents © MuleSoft Inc. MUnit Operations MUnit Module 8 • Before Suite - runs BEFORE executing MUnit Test Suite • Before Test - runs BEFORE executing MUnit Test • After Test - runs AFTER executing MUnit Test • After Suite - runs AFTER executing MUnit Test Suite – Examples of use • To alter and/or clear an Object Store • Create/Initialize/Delete a Test Database or FTP Server • Test – adds a new test • Set Event – sets a mule event • Set null payload – defines a null payload for testing
  • 9. All contents © MuleSoft Inc. MUnit Tools Operations MUnit Tools Module 9 • Assert - validate the state of a Mule event’s content – Equals – Expression – That • Mock when - mock an event processor when it matches the defined name and attributes • Spy - what happens before/after an event processor is called • Verify call - verify if a processor was called • Fail - allows you to fail your test on purpose • Run custom - custom assertion
  • 10. All contents © MuleSoft Inc. MUnit Database Server MUnit Utils :: Database Server 10 To test code that connects with a database server, you must install a database server in your local environment to run the tests. • Option 1: Have a dedicated external database server for testing: – Maven project would not be portable – 3rd party would need to install the testing database server to compile your project • Option 2: Use MUnit to implement a database server in your local environment • Define the structure and content of your database: – SQL – CSV
  • 11. All contents © MuleSoft Inc. MUnit Database Server MUnit Utils :: Database Server 11 • allows you to execute instructions on the in- memory databases • add or remove registries before a test • check if your data was stored correctly PROCESSORS • Execute - operation to insert new values to the table • Execute query- operation to retrieve all values from the table (including the newly added ones) • Validate that – validates results of a query
  • 12. All contents © MuleSoft Inc. MUnit FTP Server Operations MUnit Utils :: FTP Server 12 • To test code that connects with an FTP server, you must install an FTP server in your local environment to run the tests. • Option 1: Have a dedicated external FTP server for testing: – Maven project would not be portable – 3rd party would need to install the testing FTP server to compile your project • Option 2: Use MUnit to implement a FTP server in your local environment
  • 13. All contents © MuleSoft Inc. MUnit FTP Server Processors MUnit Utils :: FTP Server 13 • Contains files – attempts to validate the existence of a file in the FTP server – if file is not present, the processor fails causing the test to fail • Remove – instructs the FTP server to remove a file from storage – This feature is of use when we are creating the same file name several times. • Example, we can make use of it in an after-test to ensure that no name collisions cause the test to fail
  • 14. All contents © MuleSoft Inc. Create an MUnit Suite 14 Various ways to create MUnit Tests Method 1: File>New>MUnit Test Method 2 – Pallet Test Operation
  • 15. All contents © MuleSoft Inc. Adding Tests Creates XML 15 Various ways to add MUnit Test RESULTS: XML Creation Method 3- From Flow
  • 16. All contents © MuleSoft Inc. • Behavior Scope – Meant to set all the preconditions before executing the test logic – Mocks and spies go in this section • Execution Scope – Meant to have the testing logic which will wait for all processes to finish before executing the next scope – Run flows in this section • Validation Scope – Meant to have all the validations regarding the result of the execution scope – Assertions and verifications go here MUnit Test Scopes 16
  • 17. All contents © MuleSoft Inc. Set Event Set Event Processor 17 – Allows you to define a Mule Event. – Normally used at the beginning of an MUnit test, to define the first message to send to the flow being tested. – You can define as many properties per each scope as you need for your test.
  • 18. All contents © MuleSoft Inc. Assert that Assert That Event Processor 18 – Allows you to run assertions to validate the state of an event’s content – Can validate the event after the production code runs – Uses DataWeave functions called MUnit matchers to define the assertion conditions for any value in an expression – Include the prefix MunitTool:: in the expression • notNullValue() checks that the expression is not null. As shown: #[MunitTools::notNullValue()]
  • 19. All contents © MuleSoft Inc. Matchers Assert That MUnit Matchers 19 • Core Matchers - evaluate core values in the expression • String Matchers - perform assertions on String expressions • Comparable Matchers - compare the expression against a specified value • Iterable and Map Matchers - when your expression is an array or a map of data • withMediaType(String) #[MunitTools::withMediaType('text/xml’)] • containsString(String) #[MunitTools::containsString('example’)] • greaterThanOrEqualTo(Comparable) #[MunitTools::greaterThanOrEqualTo(20)] • isEmpty() #[MunitTools::isEmpty()] Examples
  • 20. All contents © MuleSoft Inc. Mock when Mock When Event Processor 20 • Allows you to mock an event processor when it matches the defined name and attributes 1) Pick processor 2) Select target processor 3) Select attributes 4) Click OK
  • 21. All contents © MuleSoft Inc. Configure “Then return” section Mock When - Then Return 21 • Configure Then Return to define the type of response the mocked processor should return • It could be a payload, a variable, attributes, or even an error 1) Choose type of response 2) Click Add icon 3) Enter values 4) Click OK
  • 22. All contents © MuleSoft Inc. Spy Spy Event Processor 22 – Allows you to spy what happens before and after an event processor is called – Tells MUnit to run a set of instructions before and/or after the spied event 1) Pick processor 2) Select target processor 3) Select attributes 4) Click OK
  • 23. All contents © MuleSoft Inc. Verify Call Verify Call Event Processor 23 – Allows you to verify if a processor was called – you can validate if a specific processor has been called: • with a particular set of attributes • a specific number of times
  • 24. All contents © MuleSoft Inc. Run MUnit Suite Select src/test/munit>Run As>Munit Run MUnit Suite 24 • Right click Canvas • Select Run MUnit suite
  • 25. All contents © MuleSoft Inc. Run MUnit Test 25 Run MUnit Test • Right click In Test • Select Run MUnit test
  • 26. All contents © MuleSoft Inc. DEMO #1 on MUnit Mock When - Then Return
  • 27. All contents © MuleSoft Inc. DEMO #1 Flow Details 27
  • 28. All contents © MuleSoft Inc. DEMO #1 MUnit Details 28
  • 29. All contents © MuleSoft Inc. DEMO #1 MUnit Test Results 29
  • 30. All contents © MuleSoft Inc. DEMO #1 MUnit Test Coverage Report 30
  • 31. All contents © MuleSoft Inc. DEMO #2 on MUnit Utils :: Database Server
  • 32. All contents © MuleSoft Inc. DEMO #2 MUnit Global Elements 32
  • 33. All contents © MuleSoft Inc. DEMO #2 Flow Details 33
  • 34. All contents © MuleSoft Inc. DEMO #2 MUnit Test Global Details 34
  • 35. All contents © MuleSoft Inc. DEMO #2 MUnit Test Coverage Report 35
  • 36. All contents © MuleSoft Inc. View test results and coverage MUnit Coverage Report 36 1) All the tests for all test suites Green means successful 2) Errors: shows the reason for test failure 3) Coverage: % of the flow that were covered 4) Detailed coverage report.
  • 37. All contents © MuleSoft Inc. Failures Munit Failures 37 Munit Test Suite FAIL SUCCESS