In my last article How to generate Mule flow using RAML.
Now here in this article we will see how to write MUnit test cases for flows that were created with APIkit RAML.

Application takes a RAML file and maps it to an implementation of an API in Mule.

We will see the implementation routes that handles incoming request based on Http methods (GET, POST, PUT, DELETE) and URL using MUnit.

Now let’s start writing MUnits for routing flows:

Step 1: Generate Munit Flow from Apikit Flow: 

Right click on APIKit router–>Create Test Suite for Munit

create-munit-flows

Step 2: Run MUnit Suite:

Right click Munit flow–> select Run MUnit suite

run-munit-suite


Step 3: Flow execution sequence

Please check your MUnit test configuration if your MUnit is not behaving properly. Enable flow sources must be configured to List of Flows section as shown below:
enable-munit-flow
Then MUnit will find the source and will execute the test accordingly.

normal-flow-execution-sequence

Step 4: Coverage report:

munit-coverage-studio-report

Please find sample Mule project in Github munit-for-apikit-flow-part1-mule4


After running MUnit you will get MUnit coverage report like shown above. But If you have noticed APIKit main flow is having very less coverage percentage and it only covers resource flows. So, how we can increase or get the MUnit coverage for APIKit main flow which includes exception handling processors?

error-flow-execution-sequence

For this you needed to write MUnit additionally to cover these scenario which I will explain in my next article.

Happy Learning 🙂

By Manish Kumar

I am having around 10 years of IT experience in Integration Architecture, Requirement gathering, Effort Estimation, Application Design\Development\Testing and Deployment including 5+ years of experience in MuleSoft ESB and Hybrid Integrations. DevOps and Cloud Integration is my area of interest.

9 thoughts on “MUnit coverage for APIKit flows Part1 – Mule4”
  1. Hi there, I found your site via Google while searching for a related topic, your website came up, it looks good. I have bookmarked it in my google bookmarks.

  2. I think other site proprietors should take this website as an model, very clean and excellent user friendly style and design, let alone the content. You are an expert in this topic!

  3. Hi Manish Sir Good day to you , will you please share your articles in Medium and can u please share Linkedin profile of yours

Leave a Reply

Your email address will not be published. Required fields are marked *