2016-06-17 19 views
0

ミュンヘンを使用してMuleフローをテストしていますが、フローが例外をスローしないように変数を設定するためにmockを使用しています。私がテストを実行すると、それは成功しますが、フル・スイートを実行すると、テストが失敗し、デバッグが実行され、モックはスイートとして実行されても変数を設定しません。MUnitスイートでモックが動作しませんが、テストでテストを実行すると動作します

<?xml version="1.0" encoding="UTF-8"?> 

<mule xmlns:mock="http://www.mulesoft.org/schema/mule/mock" xmlns="http://www.mulesoft.org/schema/mule/core" 
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
xmlns:munit="http://www.mulesoft.org/schema/mule/munit" xmlns:spring="http://www.springframework.org/schema/beans" 
xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/munit http://www.mulesoft.org/schema/mule/munit/current/mule-munit.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
http://www.mulesoft.org/schema/mule/mock  http://www.mulesoft.org/schema/mule/mock/current/mule-mock.xsd"> 
<munit:config name="munit" doc:name="MUnit configuration" /> 
<spring:beans> 
    <spring:import resource="classpath:endpointproject.xml" /> 
</spring:beans> 

<munit:test 
    name="test_FilePickUpFlow_CallsFileToStringTransformer_ExactlyOnce" 
    description="Test"> 
    <flow-ref name="filePickUpFlow" doc:name="filePickUpFlow" /> 
    <mock:verify-call messageProcessor="file:file-to-string-transformer" 
     times="1" doc:name="Verify Call" /> 
</munit:test> 

<munit:test 
    name="test_FilePickUpFlow_CallsJsonToObjectTransformer_ExactlyOnce" 
    description="MUnit Test"> 
    <flow-ref name="filePickUpFlow" doc:name="filePickUpFlow" /> 
    <mock:verify-call messageProcessor="json:json-to-object-transformer" 
     times="1" doc:name="Verify Call" /> 
</munit:test> 

<munit:test name="test_FilePickUpFlow_CallsJsonParseSubFlow_ExactlyOnce" 
    description="Validate calls to sub flows are being done properly "> 
    <set-payload 
     value="[{&quot;protocol&quot;:&quot;http&quot;,&quot;host&quot;:&quot;0.0.0.0&quot;,&quot;port&quot;:&quot;8085&quot;,&quot;path&quot;:&quot;&quot;,&quot;operation&quot;:&quot;GET&quot;}]" 
     doc:name="Set Payload" /> 
    <flow-ref name="filePickUpFlow" doc:name="filePickUpFlow" /> 
    <mock:verify-call messageProcessor="mule:sub-flow" 
     doc:name="Verify Call" times="1"> 
     <mock:with-attributes> 
      <mock:with-attribute name="name" 
       whereValue="#[matchContains('jsonParseSubFlow')]" /> 
     </mock:with-attributes> 
    </mock:verify-call> 
</munit:test> 

<munit:test name="test_httpInboundFlow_CallsSetPayload_ExactlyOnce" 
    description="MUnit Test"> 
    <flow-ref name="httpInboundFlow" doc:name="httpInboundFlow" /> 
    <mock:verify-call messageProcessor="set-payload" 
     doc:name="Verify Call" /> 
</munit:test> 

<munit:test 
    name="test_HttpInboundFlow_CallsJsonToObjectTransformer_ExactlyOnce" 
    description="MUnit Test"> 
    <munit:set payload="#[]" doc:name="Set Message"> 
     <munit:inbound-properties> 
      <munit:inbound-property key="http.query.params" 
       value="ParameterMap{[json=[[{&quot;protocol&quot;:&quot;http&quot;,&quot;host&quot;:&quot;0.0.0.0&quot;,&quot;port&quot;:&quot;8085&quot;,&quot;path&quot;:&quot;&quot;,&quot;operation&quot;:&quot;GET&quot;}]]]}" /> 
     </munit:inbound-properties> 
    </munit:set> 
    <flow-ref name="httpInboundFlow" doc:name="httpInboundFlow" /> 
    <mock:verify-call messageProcessor="json:json-to-object-transformer" 
     doc:name="Verify Call" times="1" /> 
</munit:test> 
<munit:test name="test_HttpInboundFlow_CallsJsonParseSubFlow_ExactlyOnce" 
    description="Validate calls to sub flows are being done properly "> 
    <mock:when messageProcessor="mule:set-payload" doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" 
       whereValue="#['Set Payload To Query Params']" /> 
     </mock:with-attributes> 
     <mock:then-return 
      payload="#['[{&quot;protocol&quot;:&quot;http&quot;,&quot;host&quot;:&quot;0.0.0.0&quot;,&quot;port&quot;:&quot;8085&quot;,&quot;path&quot;:&quot;&quot;,&quot;operation&quot;:&quot;GET&quot;}]']" /> 
    </mock:when> 
    <mock:when messageProcessor="json:json-to-object-transformer" 
     doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" whereValue="#['JSON to Object']" /> 
     </mock:with-attributes> 
     <mock:then-return 
      payload="#['[{protocol=http, host=0.0.0.0, port=8085, path=, operation=GET}]']" /> 
    </mock:when> 
    <flow-ref name="httpInboundFlow" doc:name="httpInboundFlow" /> 
    <mock:verify-call messageProcessor="mule:sub-flow" 
     times="1" doc:name="Verify Call"> 
     <mock:with-attributes> 
      <mock:with-attribute name="name" 
       whereValue="#[matchContains('jsonParseSubFlow')]" /> 
     </mock:with-attributes> 
    </mock:verify-call> 
</munit:test> 

<munit:test 
    name="test_HttpInboundFlow_CallsSetEndpointVariablesSubFlow" 
    description="MUnit Test"> 
    <mock:when messageProcessor="mule:set-payload" doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" 
       whereValue="#['Set Payload To Query Params']" /> 
     </mock:with-attributes> 
     <mock:then-return 
      payload="#['[{&quot;protocol&quot;:&quot;http&quot;,&quot;host&quot;:&quot;0.0.0.0&quot;,&quot;port&quot;:&quot;8085&quot;,&quot;path&quot;:&quot;&quot;,&quot;operation&quot;:&quot;GET&quot;}]']" /> 
    </mock:when> 
    <mock:when messageProcessor="mule:set-payload" doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" whereValue="set port variable" /> 
     </mock:with-attributes> 
     <mock:then-return payload="#[]"> 
      <mock:inbound-properties> 
       <mock:inbound-property key="port" value="8085" /> 
      </mock:inbound-properties> 
     </mock:then-return> 
    </mock:when> 
    <mock:when messageProcessor="mule:set-payload" doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" whereValue="set path variable" /> 
     </mock:with-attributes> 
     <mock:then-return payload="#[]"> 
      <mock:inbound-properties> 
       <mock:inbound-property key="path" value="#[]" /> 
      </mock:inbound-properties> 
     </mock:then-return> 
    </mock:when> 
    <mock:when messageProcessor="mule:set-payload" doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" whereValue="set host variable" /> 
     </mock:with-attributes> 
     <mock:then-return payload="#[]"> 
      <mock:inbound-properties> 
       <mock:inbound-property key="host" value="0.0.0.0" /> 
      </mock:inbound-properties> 
     </mock:then-return> 
    </mock:when> 
    <mock:when messageProcessor="mule:set-payload" doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" 
       whereValue="set protocol variable" /> 
     </mock:with-attributes> 
     <mock:then-return payload="#[]"> 
      <mock:inbound-properties> 
       <mock:inbound-property key="protocol" value="http" /> 
      </mock:inbound-properties> 
     </mock:then-return> 
    </mock:when> 
    <mock:when messageProcessor="mule:set-payload" doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" 
       whereValue="set operation variable" /> 
     </mock:with-attributes> 
     <mock:then-return payload="#[]"> 
      <mock:inbound-properties> 
       <mock:inbound-property key="operation" value="GET" /> 
      </mock:inbound-properties> 
     </mock:then-return> 
    </mock:when> 
    <munit:set payload="#[]" doc:name="Set Message"> 
     <munit:inbound-properties> 
      <munit:inbound-property key="http.query.params" 
       value="ParameterMap{[json=[[{&quot;protocol&quot;:&quot;http&quot;,&quot;host&quot;:&quot;0.0.0.0&quot;,&quot;port&quot;:&quot;8085&quot;,&quot;path&quot;:&quot;&quot;,&quot;operation&quot;:&quot;GET&quot;}]]]}" /> 
     </munit:inbound-properties> 
    </munit:set> 
    <flow-ref name="httpInboundFlow" doc:name="httpInboundFlow" /> 
    <mock:verify-call messageProcessor="mule:sub-flow" 
     doc:name="Verify Call"> 
     <mock:with-attributes> 
      <mock:with-attribute name="name" whereValue="#[matchContains('setEndpointVariablesSubFlow')]"/> 
     </mock:with-attributes> 
    </mock:verify-call> 
</munit:test> 

<munit:test name="test_HttpInboundFlow_CallsHttpEndpointSubFlow" 
    description="MUnit Test"> 
    <mock:when messageProcessor="mule:set-payload" doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" whereValue="#['Set Payload To Query Params']"/> 
     </mock:with-attributes> 
     <mock:then-return payload="#['[{&quot;protocol&quot;:&quot;http&quot;,&quot;host&quot;:&quot;0.0.0.0&quot;,&quot;port&quot;:&quot;8085&quot;,&quot;path&quot;:&quot;&quot;,&quot;operation&quot;:&quot;GET&quot;}]']"/> 
    </mock:when> 
    <mock:when messageProcessor="mule:set-payload" doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" whereValue="set port variable"/> 
     </mock:with-attributes> 
     <mock:then-return payload="#[]"> 
      <mock:inbound-properties> 
       <mock:inbound-property key="port" value="8085"/> 
      </mock:inbound-properties> 
     </mock:then-return> 
    </mock:when> 
    <mock:when messageProcessor="mule:set-payload" doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" whereValue="set path variable"/> 
     </mock:with-attributes> 
     <mock:then-return payload="#[]"> 
      <mock:inbound-properties> 
       <mock:inbound-property key="path" value="#[]"/> 
      </mock:inbound-properties> 
     </mock:then-return> 
    </mock:when> 
    <mock:when messageProcessor="mule:set-payload" doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" whereValue="set host variable"/> 
     </mock:with-attributes> 
     <mock:then-return payload="#[]"> 
      <mock:inbound-properties> 
       <mock:inbound-property key="host" value="0.0.0.0"/> 
      </mock:inbound-properties> 
     </mock:then-return> 
    </mock:when> 
    <mock:when messageProcessor="mule:set-payload" doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" whereValue="set protocol variable"/> 
     </mock:with-attributes> 
     <mock:then-return payload="#[]"> 
      <mock:inbound-properties> 
       <mock:inbound-property key="protocol" value="http"/> 
      </mock:inbound-properties> 
     </mock:then-return> 
    </mock:when> 
    <mock:when messageProcessor="mule:set-payload" doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" whereValue="set operation variable"/> 
     </mock:with-attributes> 
     <mock:then-return payload="#[]"> 
      <mock:inbound-properties> 
       <mock:inbound-property key="operation" value="GET"/> 
      </mock:inbound-properties> 
     </mock:then-return> 
    </mock:when> 
    <munit:set payload="#[]" doc:name="Set Message"> 
     <munit:inbound-properties> 
      <munit:inbound-property key="http.query.params" 
       value="ParameterMap{[json=[[{&quot;protocol&quot;:&quot;http&quot;,&quot;host&quot;:&quot;0.0.0.0&quot;,&quot;port&quot;:&quot;8085&quot;,&quot;path&quot;:&quot;&quot;,&quot;operation&quot;:&quot;GET&quot;}]]]}" /> 
     </munit:inbound-properties> 
    </munit:set> 
    <flow-ref name="httpInboundFlow" doc:name="httpInboundFlow" /> 
    <mock:verify-call messageProcessor="mule:sub-flow" 
     doc:name="Verify Call"> 
     <mock:with-attributes> 
      <mock:with-attribute name="name" whereValue="#[matchContains('httpEndpointSubFlow')]"/> 
     </mock:with-attributes> 
    </mock:verify-call> 
</munit:test> 

私はそれぞれの間で通信を持っていないようSuiteは、あなたが私はこの出来事を避けることができる方法を知っているとき、テストは異なるだろう、なぜ私が見ることができませんか?

テストに失敗したテストは、test_HttpInboundFlow_CallsHttpEndpointSubFlowです。

答えて

0

私は、誰もが何か提案を持っていない私は、なぜこのテストは、別のものに影響を与えているされて理解していない

<munit:test name="test_HttpInboundFlow_CallsJsonParseSubFlow_ExactlyOnce" 
    description="Validate calls to sub flows are being done properly "> 
    <mock:when messageProcessor="mule:set-payload" doc:name="Mock"> 
     <mock:with-attributes> 
      <mock:with-attribute name="doc:name" whereValue="#['Set Payload To Query Params']"/> 
     </mock:with-attributes> 
     <mock:then-return payload="#['[{&quot;protocol&quot;:&quot;http&quot;,&quot;host&quot;:&quot;0.0.0.0&quot;,&quot;port&quot;:&quot;8085&quot;,&quot;path&quot;:&quot;&quot;,&quot;operation&quot;:&quot;GET&quot;}]']"/> 
    </mock:when> 
    <munit:set payload="#[]" doc:name="Set Message"> 
     <munit:inbound-properties> 
      <munit:inbound-property key="http.query.params" value="ParameterMap{[json=[[{&quot;protocol&quot;:&quot;http&quot;,&quot;host&quot;:&quot;0.0.0.0&quot;,&quot;port&quot;:&quot;8085&quot;,&quot;path&quot;:&quot;&quot;,&quot;operation&quot;:&quot;GET&quot;}]]]}"/> 
     </munit:inbound-properties> 
    </munit:set> 
    <flow-ref name="httpInboundFlow" doc:name="httpInboundFlow" /> 
    <mock:verify-call messageProcessor="mule:sub-flow" 
     times="1" doc:name="Verify Call"> 
     <mock:with-attributes> 
      <mock:with-attribute name="name" 
       whereValue="#[matchContains('jsonParseSubFlow')]" /> 
     </mock:with-attributes> 
    </mock:verify-call> 
</munit:test> 

に「test_HttpInboundFlow_CallsJson {arseSubFlow_ExactlyOnce」テストを変更することで問題を解決するために管理していますか?

関連する問題