Flex Gateway新着情報
Governance新着情報
Monitoring API Managerパラメーター化されたテストスイートでは、異なる入力で同じテストが実行されます。
テストスイートのパラメーター化は、次のように設定レベルで定義されます。
<munit:config>
<munit:parameterizations>
<munit:parameterization name="firstParameterization">
<munit:parameters>
<munit:parameter propertyName="name" value="Robert"/>
<munit:parameter propertyName="lastname" value="Plant"/>
</munit:parameters>
</munit:parameterization>
<munit:parameterization name="secondParameterization">
<munit:parameters>
<munit:parameter propertyName="name" value="Jimmy"/>
<munit:parameter propertyName="lastname" value="Page"/>
</munit:parameters>
</munit:parameterization>
</munit:parameterizations>
</munit:config>
xml
テストスイートは、最初に firstParameterization
パラメーター、次に secondParameterization
パラメーターを使用して 2 回実行されます。
たとえば、フローのペイロードを設定するテストがある場合、次のような結果が想定されます。
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:munit="http://www.mulesoft.org/schema/mule/munit"
xmlns:munit-tools="http://www.mulesoft.org/schema/mule/munit-tools"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/munit http://www.mulesoft.org/schema/mule/munit/current/mule-munit.xsd
http://www.mulesoft.org/schema/mule/munit-tools http://www.mulesoft.org/schema/mule/munit-tools/current/mule-munit-tools.xsd">
<munit:config name="parameterized-test.xml">
<munit:parameterizations>
<munit:parameterization name="sumThree">
<munit:parameters>
<munit:parameter propertyName="input" value="#[1]"/>
<munit:parameter propertyName="output" value="#[2]"/>
</munit:parameters>
</munit:parameterization>
<munit:parameterization name="sumFive">
<munit:parameters>
<munit:parameter propertyName="input" value="#[2]"/>
<munit:parameter propertyName="output" value="#[4]"/>
</munit:parameters>
</munit:parameterization>
</munit:parameterizations>
</munit:config>
<munit:test name="expectFlowResult">
<munit:behavior>
<set-payload value="${input}"/>
</munit:behavior>
<munit:execution >
<flow-ref name="myFlow"/>
</munit:execution>
<munit:validation>
<munit-tools:assert-equals actual="#[payload]" expected="${output}" />
</munit:validation>
</munit:test>
</mule>
xml
異なるテストスイートで同じパラメーター化された値を使用するには、パラメーター化の値を Mule アプリケーションプロジェクトの /test/resources
ディレクトリの YAML ファイルに保存する必要があります。
firstParameterization:
name: "Robert"
lastname: "Plant"
secondParameterization:
name: "Jimmy"
lastname: "Page"
yaml
次に、それをテストスイート設定から参照します。
<munit:config>
<munit:parameterizations file="parameterizations.yaml" />
</munit:config>
xml
両方の方法を組み合わせて、パラメーター化された値をテストスイートに追加できます。
<munit:config name="parameterization-from-file-test.xml">
<munit:parameterizations file="parameterizations.yaml" >
<munit:parameterization name="thirdParameterization">
<munit:parameters>
<munit:parameter propertyName="name" value="John"/>
<munit:parameter propertyName="lastname" value="Bonham"/>
</munit:parameters>
</munit:parameterization>
</munit:parameterizations>
</munit:config>
xml
YAML ファイルとテストスイート設定で同じパラメーター化キーを定義した場合、テストスイートのパラメーター化が YAML のパラメーター化よりも優先されます。