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. I do not even know how I ended up here, but I thought this post was great. I don’t know who you are but definitely you’re going to a famous blogger if you aren’t already 😉 Cheers!

  2. Hello there, You have performed a fantastic job. I will definitely digg it and for my part suggest to my friends. I’m confident they will be benefited from this website.

  3. Yet another thing I would like to talk about is that in place of trying to match all your online degree tutorials on days that you finish off work (considering that people are tired when they go back home), try to arrange most of your instructional classes on the saturdays and sundays and only a couple of courses on weekdays, even if it means taking some time off your weekend break. This is really good because on the weekends, you will be extra rested along with concentrated with school work. Thx for the different ideas I have realized from your blog.

  4. I抣l right away grab your rss feed as I can not find your e-mail subscription link or newsletter service. Do you have any? Kindly let me know so that I could subscribe. Thanks.

Leave a Reply

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