Forum Discussion

niteesh2004's avatar
niteesh2004
Regular Visitor
4 years ago

Calling Test step on a different Test suite from setup script by passing context

Hello All,

 

I am trying to execute a Test step on a different suite at the setup script of the current Test suite. Please find my code below:

 

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


def testCase = runner.testSuite.project.testSuites["Helper_Functions"].testCases["Read_Test_Data"]

def testRunner = new WsdlTestCaseRunner(testCase, new StringToObjectMap())

testRunner.runTestStepByName("Read_Config")

 

In the read config step, I am reading properties from a config file and set those properties at the test suite scope

Using the code above, I am able to run the test step, but I am not able to pass the context to the next test suite.All the properties are being set in the called Test Suite scope, I want them to be set at calling Test Suite scope.

 

I can achieve that at the test case level by using the code below, 

def runner = testRunner.testCase.testSuite.project.testSuites["Helper_Functions"].testCases["Read_Test_Data"].testSteps["Read_Config"].run(testRunner, context);

 

 I want my config to be read at the setup script level of the test suite and not at the test case level. Please help me with this problem. Also if you have any other ways of calling the test step from the setup script of the Test suite, please let me know

 

 

  • ZDGN's avatar
    ZDGN
    Contributor

    Hi niteesh2004 

     

    Here is my suggestion.

    Instead of putting the config properties at the TestSuite level, you should try to use the context.

    That is to say your Read_Config TestStep should use this command:

    context.setProperty("myProperty", "Property Value")

    Then inside your calling script, you can use the context to access the property:

    context.getProperty("myProperty") 

    This could make the job.

    Let me know if it helps you.

     

    David.