0
votes

In a soapui groovy script test step I've this.

context.setProperty("searchA", new searchA());
class searchA{

    def testRunner
    def searchA(testRunner){
        this.testRunner=testRunner
        }

    def search(a,b){

        def search_TestCase = testRunner.testCase.testSuite.getTestCaseByName("Search")
          search_TestCase.setPropertyValue("ABC", a)
          search_TestCase.setPropertyValue("DEF", b)
          search_TestCase.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)

        }
    }

and in an assertion script in a different test suite I am calling the above code like this.

scripts = messageExchange.modelItem.testStep.testCase.testSuite.project.testSuites["Test"]
scripts.testCases["Lib123"].testSteps["TestLib123"].run(context.getTestRunner(),context)
context.searchA.search("value1","value2")

but this gives me error "can not get property testCase on null object". whats wrong here?

1
messageExchange.modelItem.testStep is null - tim_yates
@tim_yates Its not null. On giving a log.info statement I get com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep@6078498 - user1207289
Have a read through this stackoverflow.com/help/mcve to find out what all we need to be able to help you. - SiKing

1 Answers

0
votes

I am not seeing null object error now. The issue was that testRunner is not available in script assertion so we need to create it like this in script assertion and then pass it in the caller method.

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

testCase = messageExchange.modelItem.testStep.testCase
tcRunner = new WsdlTestCaseRunner( testCase, new StringToObjectMap() );

context.searchA.search("value1","value2",tcRunner)

This thread helped me.