How to mock a Java component within Mule Flow using MUnit

后端 未结 1 1584
时光取名叫无心
时光取名叫无心 2021-01-23 17:11

I am trying to Unit test one of my sub-flows using MUnit, I need to mock out a custom Java component but I am unable to do so.

My sub-flow reads as below

1条回答
  •  伪装坚强ぢ
    2021-01-23 17:29

    So there is no problem with your mock it actually work perfectly. The problem is with Mule and a little bit with MUnit.

    Short answer, there is no fix for that right now. There is a workaround though!

    Create a new xml (as to keep it separate from your production code) Add flow (not a sub-flow) to that new xml. In the flow you just added do a flow-ref to your sub-flow. From you test, instead of doing runFlow(PROCESS_CSV_FLOW), do runFlow("the_flow_you_created").

    The longer answer is:

    The sub-flows are not real flows, they don't even share a parent class. Thus they behave a little bit different. MUnit does some stuff to make that fact transparent to the user.

    As it turns out we are not making enough, I'll create a jira in the MUnit project to tackle that issue. But hopefully you should be able to keep testing.

    0 讨论(0)
提交回复
热议问题