Forum Discussion
Alex99
Contributor
So I am quite new to SoapUI, but you could do it like this.
I created the following test steps, step 4 and 5 are disabled so that they are only triggered by step 3:
Step 1 - Request
Step 2 - Request
Step 3 - Script
Step 4 - Script
Step 5 - Script
Both steps, 1 and 2, are soap request for the following wsdl: http://www.thomas-bayer.com/axis2/services/BLZService?wsdl
Step 1 - Request -> Request:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:blz="http://thomas-bayer.com/blz/"> <soap:Header/> <soap:Body> <blz:getBank> <blz:blz>64090100</blz:blz> </blz:getBank> </soap:Body> </soap:Envelope>
Step 1 - Request -> Response:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Body> <ns1:getBankResponse xmlns:ns1="http://thomas-bayer.com/blz/"> <ns1:details> <ns1:bezeichnung>Volksbank Reutlingen</ns1:bezeichnung> <ns1:bic>VBRTDE6RXXX</ns1:bic> <ns1:ort>Reutlingen</ns1:ort> <ns1:plz>72774</ns1:plz> </ns1:details> </ns1:getBankResponse> </soapenv:Body> </soapenv:Envelope>
Step 2 - Request -> Request:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:blz="http://thomas-bayer.com/blz/"> <soap:Header/> <soap:Body> <blz:getBank> <blz:blz>85550000</blz:blz> </blz:getBank> </soap:Body> </soap:Envelope>
Step 2 - Request -> Response:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Body> <ns1:getBankResponse xmlns:ns1="http://thomas-bayer.com/blz/"> <ns1:details> <ns1:bezeichnung>Kreissparkasse Bautzen</ns1:bezeichnung> <ns1:bic>SOLADES1BAT</ns1:bic> <ns1:ort>Bautzen, Sachs</ns1:ort> <ns1:plz>02605</ns1:plz> </ns1:details> </ns1:getBankResponse> </soapenv:Body> </soapenv:Envelope>
Step 3 - Script, is a groovy script with the following code
def response1 = context.testCase.getTestStepByName("Step 1 - Request").testRequest.response.responseContent def response2 = context.testCase.getTestStepByName("Step 2 - Request").testRequest.response.responseContent def rootNode1 = new XmlSlurper().parseText(response1) def rootNode2 = new XmlSlurper().parseText(response2) def bezeichnung1 = rootNode1.'**'.find() {node -> node.name() == 'bezeichnung'} def bezeichnung2 = rootNode2.'**'.find() {node -> node.name() == 'bezeichnung'} if(bezeichnung1.equals(bezeichnung2)) { log.info "'${bezeichnung1}' does match '${bezeichnung2}' executing step 4" context.testCase.getTestStepByName("Step 4 - Script").run(null, context) } else { log.info "'${bezeichnung1}' does not match '${bezeichnung2}' executing step 5" context.testCase.getTestStepByName("Step 5 - Script").run(null, context) }
Step 4 - Script has this code:
log.info "step 4"
Step 5 - SCript has this code:
log.info "step 5"
Run the test suite and you will get the this output:
Wed Oct 24 18:09:31 CEST 2018:INFO:'Volksbank Reutlingen' does not match 'Kreissparkasse Bautzen' executing step 5 Wed Oct 24 18:09:31 CEST 2018:INFO:step 5
HimanshuTayal
7 years agoCommunity Hero
Related Content
- 5 years ago
- 2 years ago
- 10 years ago
Recent Discussions
- 22 days ago