Dighate Dighate - 2 months ago 11
Groovy Question

How to get the HTTP/REST Method Type of a testStep from groovy

I am working an a bulk update utility for large sets of SoapUI Projects.
The update will depend upon what type of REST method each Test Step is for example: POST,GET,PUT

Right now I only care about REST type test steps, so I am filtering them by :

if (testStep.config.type == "restrequest") {
log.info "REST type test step found! "
}


But, is there a way to know what method the testStep is using ?
I specially care about POST methods.

Thanks in Advance.

Answer

On the testSteps of type REST you can use getRestMethod() to get RestMethod and then getMethod() on it:

if (testStep.config.type == "restrequest") {
     log.info "REST type test step found! " 
     log.info "Method type ${ts.getRestMethod().getMethod()}"
}