我在RubyMine中运行Savon,并在事件日志中记录日志。有没有办法验证事件日志中的响应?
我正在运行的Soap调用成功,但响应包含标记,因此会影响剩余的测试步骤。如果响应包含错误,有没有办法可以停止测试?
输入:
Globals:
$soap_client_cumulus = Savon.client(
wsdl: 'http://test.com/cumulus-ws/TestSoapService?wsdl',
namespace: 'http://test.com/requests/cumulus/schema',
env_namespace: :soapenv,
namespace_identifier: :sch,
pretty_print_xml: true,
log: true,
log_level: :debug,
namespaces: {
'xmlns:sch' => 'http://test.com/requests/cumulus/schema',
'xmlns:draw' => 'http://test.com/data-dictionary/draw',
'xmlns:priz' => 'http://test.com/data-dictionary/draw'})
And(/^I send the SOAP call 'close collection'$/) do
$soap_client_pymntmgr.call(:close_collection, message: {
:"sch:collectionGroupId" => $group_id,
:attributes! => {
collectionGroupId: { 'xmlns' => 'http://test.com/requests/payment-manager/schema'}}})
我在日志中得到的回复:
Testing started at 16:25 ...
C:\Ruby23-x64\bin\ruby.exe -EUTF-8 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:\Ruby23-x64\bin/cucumber C:/Users/vande/RegressieTest/DrawTest/features/07-Close_the_collection.feature --format Teamcity::Cucumber::Formatter --expand --color -r features
D, [2018-01-08T16:25:20.697496 #6680] DEBUG -- : HTTPI GET request to test.com (net_http)
I, [2018-01-08T16:25:20.887875 #6680] INFO -- : SOAP request: http://test.com/payment-manager-ws/PaymentManagerSoapService
I, [2018-01-08T16:25:20.887875 #6680] INFO -- : SOAPAction: "checkCollectionGroup", Content-Type: text/xml;charset=UTF-8, Content-Length: 445
D, [2018-01-08T16:25:20.888375 #6680] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sch="http://test.com/requests/manager/schema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<sch:checkCollectionGroupRequest>
<sch:collectionGroupId>22422</sch:collectionGroupId>
</sch:checkCollectionGroupRequest>
</soapenv:Body>
</soapenv:Envelope>
D, [2018-01-08T16:25:20.898887 #6680] DEBUG -- : HTTPI POST request to test.com (net_http)
I, [2018-01-08T16:25:21.604963 #6680] INFO -- : SOAP response (status 200)
D, [2018-01-08T16:25:21.605460 #6680] DEBUG -- : <?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<checkCollectionGroupResponse xmlns:ns6="http://test.com/data-dictionary/ticket" xmlns:ns5="http://test.com/data-dictionary/draw" xmlns:ns4="http://test.com/data-dictionary/prize" xmlns:ns3="http://test.com/data-dictionary/common" xmlns:ns2="http://test.com/data-dictionary/client" xmlns="http://test.com/requests/manager/schema">
<success>false</success>
<error>
<code>10523</code>
<message>Collection group is already closed.</message>
</error>
</checkCollectionGroupResponse>
</soap:Body>
</soap:Envelope>
SOAP调用不会失败,但仍会返回错误。有没有办法可以在响应日志中验证/期望某个值?
答案 0 :(得分:0)
最终答案:
response = $soap_client_pymntmgr.call(:check_collection_group, message: {
:"sch:collectionGroupId" => $group_id,
:attributes! => {
collectionGroupId: { 'xmlns' => 'http://test.com/requests/manager/schema'}}})
groupresponse = response.body[:check_collection_group_response][:success]
expect(groupresponse).to eq("true")
end