我们可以为 mule 4 中的 on Error 传播创建 Munit 吗?

问题描述

错误传播 munit 应该失败还是通过? 设想: 当我收到数据库连接错误时,它会触发带有错误通知的电子邮件。流参考错误电子邮件流。流参考放置在错误传播中。 我在错误选项卡中用错误、DB CONNECTIVITY 模拟了数据库,并在 Try 块中包装了流参考。我的测试失败了。 在 munit 测试中,测试套件应该失败并显示错误消息还是通过绿色?

<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>

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)