Checking HTTP status codes in groovy

I created a service RESTfuland I am testing it in a project SOAPUI. In a test case, I want to check the response status codes HTTPin a groovyscript.

I tried using the following:

def value = messageExchange.responseHeaders["#status#"]

assert value==200

But it always gives an error and does not check (the test that I use returns 200 status code, but I do not know how to put groovy correctly)

Can anyone advise me. I do not want to perform an operation GETin groovy. I execute GETseparately with soapui and I just want to check the status codes.

+3
source share
1 answer

. SoapUI.

HTTP- (, - ), . , SoapUI , .

:

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def httpResponseHeaders = context.testCase.testSteps["testName"].testRequest.response.responseHeaders
def httpStatus = httpResponseHeaders["#status#"]
def httpStatusCode = (httpStatus =~ "[1-5]\\d\\d")[0]

log.info("HTTP status code: " + httpStatusCode)
+7

All Articles