【问题标题】:How to test variable in munit如何在munit中测试变量
【发布时间】:2017-02-10 09:25:24
【问题描述】:

我正在尝试在我的 munit 流程中测试变量,为此我在 munit 测试用例中使用了 set-message。但是,测试每次都失败。我想我在某处遗漏了一些东西。任何人都可以帮助我。以下是我的参考代码。

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

【问题讨论】:

    标签: mule munit


    【解决方案1】:

    对于在 M-unit test-suit 中测试变量,请使用 Assert equal 并在实际值字段中指定您的变量名称,例如此处的 flowVars.fvar1 并提供您将在 name uri 参数中传递的预期值。 如果实际值和预期值不匹配,则会显示测试失败消息,这是以 m 为单位测试变量的方法。

    【讨论】:

      【解决方案2】:

      你可以像这样测试变量-

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

      更多详情请见this post

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-08-26
        • 2016-10-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-05-15
        • 2015-07-05
        相关资源
        最近更新 更多