0
votes

I am trying to test Variable in my munit flow and for this I am using a set-message in munit test case. However, The test fails every time. I guess I am missing something somewhere. Could any one just help me out. Following is my code for reference.

<set-variable variableName="fvar1" variableValue="#[message.inboundProperties.'http.uri.params'.name]" doc:name="Variable">
2

2 Answers

0
votes

For testing variable in M-unit test-suit use Assert equal and specify your variable name in actual value field such as here flowVars.fvar1 and provide expected value which your going to pass in name uri parameter. If both actual and expected value didn't get match then it will show test failure message, this is way to test variable in m-unit.

0
votes

You can test variables like this -

<munit:test name="testmule-test-suite-SampleMuleFlowTest" description="Test">
    <munit:set payload="#[getResources('test.txt').asStream()]" doc:name="Set Message">
        <munit:invocation-properties>
            <munit:invocation-property key="fileName2" value="test2.txt"/>
        </munit:invocation-properties>
        <munit:inbound-properties>
            <munit:inbound-property key="originalFilename" value="test.txt"/>
        </munit:inbound-properties>
    </munit:set>
    <flow-ref name="SampleMuleFlow" doc:name="Flow-ref to SampleMuleFlow"/>
    <munit:assert-on-equals expectedValue="#[flowVars.fileName2]" actualValue="#['test2.txt']" doc:name="Assert Equals"/>
</munit:test>

See this post for more details.