mulemule-studiomulesoftmunit

How to design a Munit4 test to execute a partial of a flow?


I have a subflowA which calls another subflowB. eg: subflowA : doing authentication, with hTTP request subflow B: after successful authentication, it retrieves data.

I would like to test subflowA's authentication process only. If I create munit and select a flow for execution (ie: subflowA), which has the reference to subflowB too. So. my test continues to run other flows too. How Can i break munit4 to run only authentication process?

eg :

<subflow name='A'>
  <http :request .....>
   </http:request>
   ..
  <flow-ref 
            name="subflowB" />
</subflow>

Solution

  • Easiest Way to achieve is by : create a subFlow C which contains the following

    <subflow name=' C'>
      <flow-ref name="subflowA" />
      <flow-rer name = "subflowB"/>
    </subflow>
    

    In this case, you can test subflowA and subflowB separately without any issues.

    or you can stick to your current design and mock the subflowB as https://docs.mulesoft.com/munit/1.3/mock-message-processor#defining-mocks