MuleSoft Integration Testing Using MUnit Tool

MUnit is a framework provided by MuleSoft to perform the unit testing and integration testing. It validates the flow in MuleESB and provides set of tools (connectors), such as a Message Processor mocking tests to make Automation easy.

Overview:

MUnit is a framework provided by MuleSoft to perform the unit testing and integration testing. It validates the flow in MuleESB and provides set of tools (connectors), such as a Message Processor mocking tests to make Automation easy. One of the benefits of MUnit is that it  verifies whether an org is integrated properly or not. With the help of MUnit, we can achieve best Automation test coverage in MuleESB.

  • Unit testing: Validation of smallest unit of code.
  • Integration testing: Validation of collaboration of units.

Boundaries:

  • Write short flows: Since the large flow has so many logic/rules, we need to split the flow into short flows.
  • Modularize: Divide your application based on functional areas. Don’t write everything into single xml file but create different xml files and add your flows depending on the goal of the flow.
  • Environmentalism: Always use placeholder in your code wherever you can, especially for outbound connecters like DB which are going to change based on environment.
  • Readability and Maintainability: Always use proper names to understand easily
  • Error Message: Always throw proper error messages.

Configuration Framework:

Step 1:

  • Open ‘Anypoint Studio’
  • Click on ‘HELP’ (In toolbar)
  • A dropdown list is shown
  • Click on ‘Install New Software’
  • Search box- paste ‘MUnit Update Sit http://studio.mulesoft.org/r5/munit’

Step 2:

  • Click the checkboxes shown in the following figure
  • Click the Next button to install
  • Click the Finish button to complete the MUnit configuration

MUnit tool

Mule Studio

MUnit tool

Fig 1.1: Client Org

Salesforce Configuration: Here I Query the records from an Inbound Salesforce endpoint.

MUnit tool

Fig 1.2: Customer Org

Salesforce Configuration: Here I get input from an Inbound Salesforce endpoint as a payload and pass it to an Outbound Salesforce endpoint.

MUnit tool

Fig 1.3: Studio Configuration Results

Postman: Need to pass the URL to kick start the integrated Flow.

Fig 1.4: Tracker message shown

Console: In this, we get the tracker message to show the status of the configuration.

Fig 1.5: MUnit Flow in Mule Studio

Mock: It is an inbound connector which mocks all Inbound endpoints in our flows while running MUnit test cases.

Flow Reference: Here it refers the Mule flow

Assert Equal: This will check whether the name of the record is equal or not

Mulesoft Integration Testing

Fig 1.6: Run Munit suite

MUnit tool

Fig 1.7: Results of MUnit test cases

Once it completes, if there are no errors in integration between the both Org, then it will show result as below.

MUnit tool

Fig 1.8: Failed test cases

If there are any integration issues, then we get the results as below.

MUnit tool

About MST

At MST Solutions our cornerstone is to adapt, engage and create solutions which guarantee the success of our clients. The talent of our team and experiences in varied business verticals gives us an advantage over other competitors.

Recent Articles

Work with us.

Our people aren’t just employees, they are key to the success of our business. We recognize the strengths of each individual and allow them time and resources to further develop those skills, crafting a culture of leaders who are passionate about where they are going within our organization.