如何验证 SOAP 响应的多个输出
How to validate multiple output from SOAP response
我正在尝试验证下面的 XML SOAP 响应,但它不起作用。请让我知道正确的方法。如果需要更多信息,请告诉我。
回复XML:
<GetTariffsInfoResult>
<Status>
<StatusCode>0</StatusCode>
<StatusDescription>SUCCESS</StatusDescription>
</Status>
<OutputParameterSets>
<OutputParameterSet>
<OutputParameters>
<OutputParameter>
<Name>COMP_AVAILABLE</Name>
<Value>TRUE</Value>
</OutputParameter>
<OutputParameter>
<Name>ILEC_VENDORNAME</Name>
<Value>COMP1</Value>
</OutputParameter>
<OutputParameter>
<Name>ABC</Name>
<Value>FALSE</Value>
</OutputParameter>
<OutputParameter>
<Name>TEST</Name>
<Value>Identical</Value>
</OutputParameter>
</OutputParameters>
</OutputParameterSet>
</OutputParameterSets>
</GetTariffsInfoResult>
特征
Scenario: Check Request and Respone xml
* set /Envelope/Body/GetTariffsInfoResponse/GetTariffsInfoResult
| Path | Value |
| OutputParameter[1]/Name | 'QOS_AVAILABLE' |
| OutputParameter[1]/Value | 'True' |
| OutputParameter[2]/Name | 'ILEC_VENDORNAME' |
| OutputParameter[2]/Value | 'CENTURYTEL OF MW-WISCONSIN LLC DBA CENTURYLINK - NORTH' |
| OutputParameter[3]/Name | 'QC' |
| OutputParameter[3]/Value | 'FALSE' |
| OutputParameter[4]/Name | 'ELA_PREMIER_TYPE' |
| OutputParameter[4]/Value | 'Identical' |
| OutputParameter[5]/Name | 'QOS_ALIGNMENT' |
| OutputParameter[5]/Value | 'Y' |
| OutputParameter[6]/Name | 'QOS_IDENTICAL' |
| OutputParameter[6]/Value | 'Y' |
| OutputParameter[7]/Name | 'QOS_MEDIUM' |
| OutputParameter[7]/Value | 'Y' |
| OutputParameter[8]/Name | 'QOS_NONE' |
| OutputParameter[8]/Value | 'Y' |
#|path
Given request read('request.xml')
When soap action 'XYZ'
Then status 200
And match /Envelope/Body/GetTariffsInfoResponse/GetTariffsInfoResult/Status/StatusCode == 0
And match /Envelope/Body/GetTariffsInfoResponse/GetTariffsInfoResult == read('Excepted.xml')
And print 'response: ', response
And match / == read('Excepted.xml')
在此功能中,一切都通过了,只有最后一步失败了 "And match / == read('Excepted.xml')"。这是抛出实际作为'(不存在')
以后请简化你的例子,不要把你的全部工作都扔在这里。
当您执行 match /
时,您正在尝试匹配从根开始的完整 XML。我建议您只需匹配您需要的零件,让生活变得简单。
您可以将以下内容剪切并粘贴到新的 Scenario:
中并尝试一下。您会发现您犯的一个错误是 table 列 path
和 value
应该是小写的。我还向您展示了如何使用 XML 本身作为预期结果,而不是痛苦地创建 table。仔细阅读文档并参考此文件以获取很好的示例:xml.feature
* def response =
"""
<GetTariffsInfoResult>
<Status>
<StatusCode>0</StatusCode>
<StatusDescription>SUCCESS</StatusDescription>
</Status>
<OutputParameterSets>
<OutputParameterSet>
<OutputParameters>
<OutputParameter>
<Name>COMP_AVAILABLE</Name>
<Value>TRUE</Value>
</OutputParameter>
<OutputParameter>
<Name>ILEC_VENDORNAME</Name>
<Value>COMP1</Value>
</OutputParameter>
<OutputParameter>
<Name>ABC</Name>
<Value>FALSE</Value>
</OutputParameter>
<OutputParameter>
<Name>TEST</Name>
<Value>Identical</Value>
</OutputParameter>
</OutputParameters>
</OutputParameterSet>
</OutputParameterSets>
</GetTariffsInfoResult>
"""
* set expected /OutputParameters
| path | value |
| OutputParameter[1]/Name | 'COMP_AVAILABLE' |
| OutputParameter[1]/Value | 'TRUE' |
| OutputParameter[2]/Name | 'ILEC_VENDORNAME' |
| OutputParameter[2]/Value | 'COMP1' |
| OutputParameter[3]/Name | 'ABC' |
| OutputParameter[3]/Value | 'FALSE' |
| OutputParameter[4]/Name | 'TEST' |
| OutputParameter[4]/Value | 'Identical' |
* match /GetTariffsInfoResult/OutputParameterSets/OutputParameterSet/OutputParameters == expected
* match /GetTariffsInfoResult/OutputParameterSets/OutputParameterSet/OutputParameters ==
"""
<OutputParameters>
<OutputParameter>
<Name>COMP_AVAILABLE</Name>
<Value>TRUE</Value>
</OutputParameter>
<OutputParameter>
<Name>ILEC_VENDORNAME</Name>
<Value>COMP1</Value>
</OutputParameter>
<OutputParameter>
<Name>ABC</Name>
<Value>FALSE</Value>
</OutputParameter>
<OutputParameter>
<Name>TEST</Name>
<Value>Identical</Value>
</OutputParameter>
</OutputParameters>
"""
我正在尝试验证下面的 XML SOAP 响应,但它不起作用。请让我知道正确的方法。如果需要更多信息,请告诉我。
回复XML:
<GetTariffsInfoResult>
<Status>
<StatusCode>0</StatusCode>
<StatusDescription>SUCCESS</StatusDescription>
</Status>
<OutputParameterSets>
<OutputParameterSet>
<OutputParameters>
<OutputParameter>
<Name>COMP_AVAILABLE</Name>
<Value>TRUE</Value>
</OutputParameter>
<OutputParameter>
<Name>ILEC_VENDORNAME</Name>
<Value>COMP1</Value>
</OutputParameter>
<OutputParameter>
<Name>ABC</Name>
<Value>FALSE</Value>
</OutputParameter>
<OutputParameter>
<Name>TEST</Name>
<Value>Identical</Value>
</OutputParameter>
</OutputParameters>
</OutputParameterSet>
</OutputParameterSets>
</GetTariffsInfoResult>
特征
Scenario: Check Request and Respone xml
* set /Envelope/Body/GetTariffsInfoResponse/GetTariffsInfoResult
| Path | Value |
| OutputParameter[1]/Name | 'QOS_AVAILABLE' |
| OutputParameter[1]/Value | 'True' |
| OutputParameter[2]/Name | 'ILEC_VENDORNAME' |
| OutputParameter[2]/Value | 'CENTURYTEL OF MW-WISCONSIN LLC DBA CENTURYLINK - NORTH' |
| OutputParameter[3]/Name | 'QC' |
| OutputParameter[3]/Value | 'FALSE' |
| OutputParameter[4]/Name | 'ELA_PREMIER_TYPE' |
| OutputParameter[4]/Value | 'Identical' |
| OutputParameter[5]/Name | 'QOS_ALIGNMENT' |
| OutputParameter[5]/Value | 'Y' |
| OutputParameter[6]/Name | 'QOS_IDENTICAL' |
| OutputParameter[6]/Value | 'Y' |
| OutputParameter[7]/Name | 'QOS_MEDIUM' |
| OutputParameter[7]/Value | 'Y' |
| OutputParameter[8]/Name | 'QOS_NONE' |
| OutputParameter[8]/Value | 'Y' |
#|path
Given request read('request.xml')
When soap action 'XYZ'
Then status 200
And match /Envelope/Body/GetTariffsInfoResponse/GetTariffsInfoResult/Status/StatusCode == 0
And match /Envelope/Body/GetTariffsInfoResponse/GetTariffsInfoResult == read('Excepted.xml')
And print 'response: ', response
And match / == read('Excepted.xml')
在此功能中,一切都通过了,只有最后一步失败了 "And match / == read('Excepted.xml')"。这是抛出实际作为'(不存在')
以后请简化你的例子,不要把你的全部工作都扔在这里。
当您执行 match /
时,您正在尝试匹配从根开始的完整 XML。我建议您只需匹配您需要的零件,让生活变得简单。
您可以将以下内容剪切并粘贴到新的 Scenario:
中并尝试一下。您会发现您犯的一个错误是 table 列 path
和 value
应该是小写的。我还向您展示了如何使用 XML 本身作为预期结果,而不是痛苦地创建 table。仔细阅读文档并参考此文件以获取很好的示例:xml.feature
* def response =
"""
<GetTariffsInfoResult>
<Status>
<StatusCode>0</StatusCode>
<StatusDescription>SUCCESS</StatusDescription>
</Status>
<OutputParameterSets>
<OutputParameterSet>
<OutputParameters>
<OutputParameter>
<Name>COMP_AVAILABLE</Name>
<Value>TRUE</Value>
</OutputParameter>
<OutputParameter>
<Name>ILEC_VENDORNAME</Name>
<Value>COMP1</Value>
</OutputParameter>
<OutputParameter>
<Name>ABC</Name>
<Value>FALSE</Value>
</OutputParameter>
<OutputParameter>
<Name>TEST</Name>
<Value>Identical</Value>
</OutputParameter>
</OutputParameters>
</OutputParameterSet>
</OutputParameterSets>
</GetTariffsInfoResult>
"""
* set expected /OutputParameters
| path | value |
| OutputParameter[1]/Name | 'COMP_AVAILABLE' |
| OutputParameter[1]/Value | 'TRUE' |
| OutputParameter[2]/Name | 'ILEC_VENDORNAME' |
| OutputParameter[2]/Value | 'COMP1' |
| OutputParameter[3]/Name | 'ABC' |
| OutputParameter[3]/Value | 'FALSE' |
| OutputParameter[4]/Name | 'TEST' |
| OutputParameter[4]/Value | 'Identical' |
* match /GetTariffsInfoResult/OutputParameterSets/OutputParameterSet/OutputParameters == expected
* match /GetTariffsInfoResult/OutputParameterSets/OutputParameterSet/OutputParameters ==
"""
<OutputParameters>
<OutputParameter>
<Name>COMP_AVAILABLE</Name>
<Value>TRUE</Value>
</OutputParameter>
<OutputParameter>
<Name>ILEC_VENDORNAME</Name>
<Value>COMP1</Value>
</OutputParameter>
<OutputParameter>
<Name>ABC</Name>
<Value>FALSE</Value>
</OutputParameter>
<OutputParameter>
<Name>TEST</Name>
<Value>Identical</Value>
</OutputParameter>
</OutputParameters>
"""