使用groovy步骤命中URL

时间:2016-06-22 07:19:47

标签: groovy soapui

我创建了一个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"
   }         

0 个答案:

没有答案