Unit Testing in Mule with MUnit

home

MUnit is the Mule testing framework that allows developers using Anypoint Platform to code functional, integration, or unit tests for Mule applications through an intuitive API fully integrated with Anypoint Studio. Once developed, these tests can be isolated, debugged, and automated from Anypoint Studio to maximize development productivity.

Documentation

MUnit tests can be written in Mule or Java, and MUnit is fully integrated with Maven and Surefire for extensibility into your continuous integration environment. With MUnit, a number of flow elements can be enabled, disabled, and mocked:

  • Enable/Disable Inbound endpoints: HTTP, JMS, FTP/SFTP
  • Mock Message processors (MP): any Mule component that is not a router, scope or filter (e.g. Anypoint Connectors, transformers)
  • Mock Outbound endpoints: JDBC outbound endpoints, HTTP outbound endpoints

Within an MUnit test suite, developers have access to a full suite of testing tools

  • Assertions for Mule messages to ensure the Mule message is what you expect.
  • Mocking of components inside a Mule flow (the service doesnโ€™t need to be running in production).
  • Verify calls and test the # of times an MP has been called: exactly one, at least #, at most #.
  • Spy on an MP before/after execution: Inspect the Mule message before/after calling a MP.
  • Set up and tear down sections for test suites.
  • Custom Assertions: Extend the framework as you see fit (for example, to create a complex validation).

Read Full Documentation

MUnit Tutorial

This simple, short tutorial takes you through the process of creating a series of MUnit tests, which are aimed at validating the behavior of a simple code example. This tutorial uses only core components of Mule Runtime. No Anypoint Connectors are used; however, you can easily apply what you learn to Anypoint Connectors.

Read Full Tutorial

Using MUnit in Studio

MUnit is pre-installed in Anypoint Studio.(https://docs.mulesoft.com/munit/v/1.3/using-munit-in-anypoint-studio).

TypeCustom
OrganizationMuleSoft
Published by
MuleSoft Organization
Published onJul 25, 2017
Asset overview

Asset versions for 1.0.x

Asset versions
VersionActions
1.0.0