harry21
9 years agoOccasional Contributor
Groovy - Fail and Abort the test execution for 500 ISE and continue to run on 4x error codes
I am new to SOAPUI & Groovy.
I am trying to run from the TestSuite level.. I need to set a Script Assertion on each Test step to make sure the execution should be aborted if the service returns 500 error code. This groovy should continue to run in case we get 400, 404 etc and should not bother about these 4x error codes. i.e. only if we get 500 ISE on any step within the test case, then execution should not proceed.
I tried this below Groovy.
But it still proceeding the next steps and also I'm getting the message "No such property: testRunner for class"
import java.io.*; import java.util.*; import com.eviware.soapui.model.testsuite.* import com.eviware.soapui.impl.wsdl.teststeps.assertions.* import com.eviware.soapui.SoapUI def alert = com.eviware.soapui.support.UISupport; def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) def httpResponseHeaders = context.testCase.testSteps["Request"].testRequest.response.responseHeaders def httpStatus = httpResponseHeaders["#status#"] def httpStatusCode = (httpStatus =~ "[1-5]\\d\\d")[0] if (httpStatusCode == "200") { testRunner.testCase.cancel() } else log.info("HTTP status code: " + httpStatusCode)
I even tried the below piece of code.
testRunner.testCase.fail()
testRunner.testCase.cancel()
testRunner.testCase.testSuite.fail()
Please help out with this