我创建了一个HTTP请求步骤并检查了响应代码200/400。 同样我想只使用groovy检查。没有HTTP请求步骤。只使用groovy步骤。
网址回复脚本: -
def rawResponse = new String(testRunner.testCase.testSteps["HTTP Request"].testRequest.response.rawResponseData)
log.info rawResponse
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def httpResponseHeaders = context.testCase.testSteps["HTTP Request"].testRequest.response.responseHeaders
def httpStatus = httpResponseHeaders["#status#"]
def httpStatusCode = (httpStatus =~ "[1-5]\\d\\d")[0]
log.info("HTTP status code: " + httpStatusCode)
if (httpStatusCode == "200")
{
log.info "Success"
}
else
{
log.info "Failure"
}