Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Engineering Student MuleSoft Meetup#4 - API Testing With MuleSoft
1. 5th May 2022 , 09:00 PM (IST)
Engineering Student Meetup Group
Testing With MuleSoft
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 & AnswersTab.
Make it more Interactive!!!
Give us feedback! Rate this meetup session by filling feedback form at the end of theday.
We Love Feedbacks!!! Its Bread & Butter for Meetup.
Housekeeping
3
9. 9
Testing: Finding out how well something works.
▪ Testing is a process of verifying if the coding has met its design and expectations.
Testing Stages:
● Unit testing: Validating that each software unit
performs as expected.
● System testing: is the first level in which the
complete application is tested as a whole.
● Integration testing: Ensuring that software
components or functions operate together.
● Acceptance testing: User Acceptance Testing
is conducted to determine whether the system
is ready for release.
● Performance testing: To evaluate the software
performs under different workloads and real-
life load.
● Regression testing: Sanity testing can be used
to verify menus.
● Stress testing: Testing how much strain the
system can take before it fails.
Testing Types:
1. Manual - Test cases are written and executed
manually without using any automated tool.
2. Automation - Software testing techniques are used
to test and compare the actual outcome with the
expected outcome. This can be achieved by writing
test scripts or using any automation testing tool.
10. 10
Unit Testing: Testing your own code.
Unit:- A unit is the smallest testable component of an
application. For eg: individual component, transform message,
flow, condition etc..
Unit Testing: - Testing small single unit of software.
● Unit tests are typically automated tests written and run by
software developers.
● Designed to ensure that a section of an application meets
its requirements.
● Application behaves as intended for possible known
scenarios.
Testing Tools:
● Postman
Collections
● Studio Embedded
Munit
● REST Client
12. 12
When you perform Unit testing, Verify:
▪ HTTP status code.
▪ Returns an expected value/payload.
▪ Verify input Headers.
▪ Verify input params (URI prams, Query params).
▪ Throws an exception under the tested condition.
▪ Changes the state of the system.
▪ Null checks
15. 15
MUnit Overview
MUnit is fully integrated with Anypoint Studio, allows you to create, design and run MUnit tests just like
you would Mule applications.
You can use Studio’s graphical interface to:
● Create and design MUnit tests.
● Run your tests.
● View test results and coverage.
● Debug your tests.
MUnit suit creation in Studio:
1. Using API specification :
You can use APIKit to automatically generate an empty structure for an MUnit test suite based on
your API specification.
1. Test Recorder in Studio:
The test recorder enables you to record a processing flow and then configure a unit test based on the
captured event.
16. MUnit Test features & Components
MUnit has a set of dedicated event processors to validate, assert, and mock the content and status of the Mule event so you
can run automatic tests against your Mule applications.
Features:
● A testing framework for Mule applications.
● Anypoint studio embedded testing framework.
● Developers needs to write the Unit Tests.
● Automated test cases.
● Coverage
MUnit Dependency:
<dependency>
<groupId>com.mulesoft.munit</groupId>
<artifactId>munit-runner</artifactId>
<version>2.3.0</version>
<classifier>mule-plugin</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mulesoft.munit</groupId>
<artifactId>munit-tools</artifactId>
<version>2.3.7</version>
<classifier>mule-plugin</classifier>
<scope>test</scope>
</dependency>
17. 17
MUnit Coverage Report:
The MUnit Coverage feature provides a measurement of how much of a Mule application has
been executed by a set of MUnit tests.
● Application overall coverage - An average of all items in an application.
● Resource coverage - Mule configuration file under src/main/mule
● Flow coverage - Flows, Sub-flows, and Batch jobs.
19. Mnit testing Best Practices
1. Each Unit Test should verify an individual component such as transforms (DataWeave)
or sub-flows.
2. Mock any external dependencies and systems.
3. Munit coverage >80%.
4. Write negative test cases to each resources.
5. Write additional cases for validation, choice or conditional components.
Unit Testing Benefits:
● Reduces errors
● Boosts Productivity
● Saves Time
● Integrity of Code
● Code validation
23. 23
Question 1
The test levels are performed in which of the following order?
1) Unit, Integration, System, Acceptance
2) It is based on the nature of the project
3) Unit, Integration, Acceptance, System
4) Unit, System, Integration, Acceptance
24. 24
Question 2
Which of the following is not a Munit event processor?
1) Mock when
2) Verify Call
3) Set Payload
4) Spy
25. 25
Question 3
Which combination of the components an Munit test suit can
contain?
1) Before/After Suites
2) Before/After Tests
3) MUnit tests
4) All of the above
27. Take a stand !
18
●Nominate yourself for the next meetup speaker and suggest a topic as well.
28. 20
● Share:
○ Tweet using the hashtag #MuleSoftMeetups
○ Invite your network to join: https://meetups.mulesoft.com/engineering-student-
group/
● 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?