DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • Scaling Site Reliability Engineering (SRE) Teams the Right Way
  • Automating the Migration From JS to TS for the ZK Framework
  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
  • Never Use Credentials in a CI/CD Pipeline Again

Trending

  • Scaling Site Reliability Engineering (SRE) Teams the Right Way
  • Automating the Migration From JS to TS for the ZK Framework
  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
  • Never Use Credentials in a CI/CD Pipeline Again
  1. DZone
  2. Data Engineering
  3. Databases
  4. MUnit With Mule 4.0

MUnit With Mule 4.0

This article will describe how to use MUnit 2.0 to create a test case for an application in Mule 4.0.

Varun Goyal user avatar by
Varun Goyal
·
Jul. 17, 18 · Tutorial
Like (5)
Save
Tweet
Share
28.18K Views

Join the DZone community and get the full member experience.

Join For Free

This article will describe how to use MUnit 2.0 to create a test case for an application in Mule 4.0. MUnit is a mule application testing framework that allows you to easily build automated tests for your integrations and API's.

In the below application flow, the records are fetched from the MySQL database. Steps to be considered are as follows:

Image title

  • HTTP listener is configured to receive the request named as Listener.

  • Database Select operation is used to fetch data from the database where the operation takes input parameters from HTTP queryParams. Below is the configuration of the database:

Image title

SQL Query Text along with Input Parameters are as follows:

Image title

In the transform message to get the response payload as STATUS:

Image title

Logger will print the payload within the Console. Now we will create an MUnit test framework for the application, shown below:

  • Right-click on Project, Go to --> New--> MUnit test. Give the name to the test and select the flow for which test case is to be created.

MUnit Differences Mule 3.8 and Mule 4.0:

Image title

Earlier, all Mule functions were in a single category, but in Mule 4.0, they are properly grouped under two categories: MUnit and MUnit Tools. Naming conventions are also changed in the Mule 4.0 version.

A flow of the MUnit test case is shown below:

Image title

Drag-and-Drop a set event operation from Mule Palette in the Execution section that is used to pass any payload and flow variables for testing. Here, we are passing variables in the flow. Click on Add property and give the Name and Value for the variable.

Image title

Now, drag and drop the Assert that under the Validation section to assert and validate the payload. Pass the payload in the expression, Is: notNullValue(), specify an error Message which needs to be given when the test case fails.

Image title

Note: Don't forget to go back to Mule flow and Modify the values to be given in the flow. Go to input parameters of the database and change the queryParams as shown:

Image title

Now run the MUnit Test flow, and we can see a green color mark in the MUnit module that indicates that the test case has passed successfully. Now, change the values for which there is no entry in the database and you will see a red color mark for the failed test case as shown:

Image title

We can see the message will show the expected value set.

Happy learning!

Test case Database Testing Flow (web browser)

Opinions expressed by DZone contributors are their own.

Trending

  • Scaling Site Reliability Engineering (SRE) Teams the Right Way
  • Automating the Migration From JS to TS for the ZK Framework
  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
  • Never Use Credentials in a CI/CD Pipeline Again

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: