Adsense

November 10, 2019

MUnit coverage for APIKit flows Part1 - Mule4

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 :)

No comments:

Post a Comment