Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a test step in Script assertion SOAP UI

Tags:

groovy

soapui

I have 5 test steps in a test case and i want to write a script assertion for a test step

Like

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

I want to re-run the test step named as step 1

I know that testRunner class is not present in Script assertion is there a way to do it with messageExchange variable class

I saw an answer on stack overflow

`messageExchange.modelItem.testStep.testCase.getTestStepByName("Step1").run(context.getTestRunner(),context)`

I tried the code but as soon as i click run SOAP UI hangs and I have to force close the SOAP UI application

like image 963
Abhilash Battu Avatar asked Jun 24 '26 18:06

Abhilash Battu


1 Answers

To run a test step from script assertion you may use this

    import com.eviware.soapui.support.types.StringToObjectMap
    import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner

    def Runner = new WsdlTestCaseRunner(messageExchange.modelItem.testStep.testCase, new StringToObjectMap())

yourTestStep= messageExchange.modelItem.testStep.testCase.testSuite.project.testSuites["ScriptLibrary"].testCases["Library"].testSteps["Lib"]


    yourTestStep.run(Runner,context)
like image 190
user1207289 Avatar answered Jun 29 '26 05:06

user1207289