Soapui可以在两个请求的输出之间断言吗? 我想检查输出中的值是否等于来自另一个输出的值。
答案 0 :(得分:4)
是的,你可以! :-)
这是一个Groovy脚本,可以在我的soapUI v2.5.2中运行(它是专业的,但这也适用于免费版本):
def r1 = context.testCase.testSteps["Request #1"].properties["Response"]
def response1 = r1["value"]
def r2 = context.testCase.testSteps["Request #2"].properties["Response"]
def response2 = r2["value"]
log.info "Request #1 response: $response1"
log.info "Request #2 response: $response2"
assert response1 == response2
我希望这也适合你。
干杯!
Shonzilla
答案 1 :(得分:2)
另一个有效:
def myContext1 = new com.eviware.soapui.support.GroovyUtils( context )
holderOpConfirmation = myContext1.getXmlHolder ("opConfirmation3 - Request 2#Response")
holderOpConfirmation.namespaces["bilhete"] = "http://bilhete.ic.cp.fujitsu"
def ticketNo1 = holderOpConfirmation[ "//bilhete:ticketNo//bilhete:number" ]
log.info "ticketNo1: $ticketNo1"
//Segundo Bilhete
def myContext2 = new com.eviware.soapui.support.GroovyUtils( context )
holderGetNullifiedTickets = myContext2.getXmlHolder ("getNullifiedTickets - Request 1#Response")
holderGetNullifiedTickets.namespaces["bilhete"] = "http://bilhete.ic.cp.fujitsu"
def ticketNo2 = holderGetNullifiedTickets[ "//bilhete:getNullifiedTicketsReturn" ]
log.info "Numero bilhete 2: $ticketNo2"
if (!ticketNo2.contains(ticketNo1)) {
com.eviware.soapui.support.UISupport.showInfoMessage(
"O bilhete " + ticketNo1 + " nao se encontra entre os bilhetes anulados manualmente.\n" +
"Por favor verifique a data do relatorio nas propriedades do teste");
}
// Garantir que a data de "getNullifiedTickets - Request 1" é um dia anterior à data da volta do askPlaces original
assert ticketNo2.contains(ticketNo1)