0

Does on Error Propagate Munit should fail or pass? Scenario: When I get db connectivity error, it triggers email with error notification. Flow reference to Error email flow. Flow reference is placed in On Error Propagate. I have mocked database with Error, DB CONNECTIVITY in error tab and wrap flow Ref in Try block. My tests are failing. Test suite should fail with error message or pass with green colour in Munit tests?

<munit:test name="implementation-suiteTest" doc:id="804123309-0b27-4e5a-beb3-5372b91eafc3" expectedErrorType="DB:QUERY_EXECUTION">
        <munit:behavior >
            <munit:set-event doc:name="Set Event" doc:id="5d0290f4-9855-42ba-b434-a4322457819c">
                <munit:payload value="#[output application/java --- readUrl('classpath://insertdatabaseFlowtest\mock_payload.dwl')]" />
            </munit:set-event>
            <munit-tools:mock-when doc:name="Mock " doc:id="d8493233-303b-4765-89b4-9ae19bdffa1f" processor="db:bulk-insert">
            <munit-tools:with-attributes>
                <munit-tools:with-attribute whereValue="b645fb60-7b08-4939-894d-a476ee58b325" attributeName="doc:id" />
            </munit-tools:with-attributes>
                <munit-tools:then-return >
                    <munit-tools:payload value="#[output application/java --- readUrl('classpath://insertdatatodatabaseFlowtest\mock_payload1.dwl')]" />
                    <munit-tools:error typeId="DB CONNECTIVITY" />
                </munit-tools:then-return>
        </munit-tools:mock-when>
            <munit-tools:mock-when doc:name="Send Email" doc:id="c9cb74e7-9b56-4634-a272-d954d4ab8fb2" processor="email:send">
                <munit-tools:with-attributes >
                    <munit-tools:with-attribute whereValue="3f8bda1c-2e22-43d8-8e0a-3da9a6653dd7" attributeName="doc:id" />
                </munit-tools:with-attributes>
                <munit-tools:then-return >
                    <munit-tools:payload value="#[output application/java --- readUrl('classpath://insertdatatodatabaseFlowtest\mock_payload2.dwl')]" />
                </munit-tools:then-return>
            </munit-tools:mock-when>
        </munit:behavior>
        <munit:execution>
            <try doc:name="Try" doc:id="e73eae0a-25fb-46bb-b0e9-e845bb7310e0" >
                <flow-ref doc:name="Flow-ref " doc:id="8582675c-3203-4f70-8988-370e82cd5249" name="insert-dataFlow" />
                <error-handler >
                    <on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="7999aa4b-4959-4c64-98c4-284f883c5778" >
                        <logger level="INFO" doc:name="Logger" doc:id="6018dc63-a176-41aa-9ca3-be39264c9e0f" />
                    </on-error-continue>
                </error-handler>
            </try>
        </munit:execution>
        <munit:validation>
            <munit-tools:assert-that doc:name="Assert that" doc:id="6b255b30-e43a-4001-a62d-e6374a9d16f0" expression="#[payload]" is="#[MunitTools::containsString('Error Email Sent')]"/>
        </munit:validation>
    </munit:test>

Thanks

anonymous
  • 81
  • 9
  • Please use text instead of images. See https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question for more details on the reason. In this case you can see the XML of the MUnit test in Studio and copy&paste the XML in your question. Additionally the try scope seems to be using an on error continue error handler, instead of propagate. – aled May 18 '21 at 19:13
  • My actual flow has on error propagate. Here at flow ref, I got error so I wrap with try block and on continue. It goes all through the email flow and come back to flow ref then on continue. Assert that or Assert equals in validation is failing. I wanted to know is on error propagate expected to fail in munits – anonymous May 18 '21 at 19:19
  • Kindly add at least a snippet from that flow showing the error handler. – aled May 18 '21 at 20:06
  • junit.framework.AssertionFailedError: The test: implementation-suiteTest was expecting a failure - Error ID: DB CONNECTIVITY but it didn't fail at junit.framework.Assert.fail(Assert.java:57) – anonymous May 18 '21 at 20:23
  • That's from the error? But what is the error handler in the flow? – aled May 19 '21 at 20:33
  • 1
    I figured out my error @aled. I have defined expected error type in Munit test flow name that's why it was throwing error. Once removed it and defined error as TypeId in mock when, it worked fine. Thanks – anonymous May 22 '21 at 18:09

0 Answers0