In my previous articles How to generate Mule flow using RAML and MUnit complete coverage for ApiKit flows Part1 – Mule4 we have seen how Mule application can be generated using APIkit RAML and how we can test our routing flows using MUnit Test Suites.


Now here in this article we will see how to write MUnit test cases for flows that were created with APIkit RAML for APIKit Validation scenarios.


APIkit Router validates the incoming requests, HTTP methods, URI and URI parameter, header and query parameters against the structure or validation defined in RAML. It also routes the message to the respective flow and serials response. Message routing consists of incoming API requests to existing Mule flows and returning outgoing HTTP response codes to exceptions.

http-error-codes

Things to consider while writing MUnits for Validation flows:


set-bad-request-status-code
Above configuration is needed to validate HTTP response code. This you can configure as per your test scenarios.

After adding MUnit for APIKit Validation flows your MUnit coverage report has been increased as shown below:

munit-flow-coverage-report-extended

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

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.

Leave a Reply

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