Is it possible to perform certain test steps in other test cases from the Groovy Script test step

Is it possible to complete certain testing steps in other test cases from the Groovy Script testing phase?

I can’t figure out how to do this.

thanks

+8
soapui
source share
3 answers

Yes it is possible. In the groovy step, you have access to testRunner, which you can use to access everything else in soapUI, and yes, to run the test steps in another test case.

So this code is on top of my head ...

def tCase = testRunner.testCase.testSuite.project.testSuites["Name of the other test suite"].testCases["name of test case you want to access"] 

or

 def tCase = testRunner.testCase.testSuite.testCases["Name of test cases"] def tStep = tCase.testSteps["test step you want to run"] tStep.run(testRunner, context) 

Check the link , this may help ...

+12
source share

For those of us who, like me, were looking for code for the current version of Ready! API

  def testStep = testRunner.testCase.testSuite.project.getTestSuiteByName("[OTHER_TEST_SUITE_NAME]").getTestCaseByName("[OTHER_TEST_CASE_NAME]").getTestStepByName("[OTHER_TEST_STEP_NAME]") testStep.run(testRunner, context) 
+3
source share

I understand that I am a little late for the party, but I thought that I would expand this topic by sending my solution to a similar problem. Hope this helps someone in the future. The solution can be scaled to cover more than two stages of testing, test cases and / or projects. This is also my first post here, so please excuse me for any noob errors. Not the most beautiful solution. It may have some redundant variables. All code blocks contain the entire solution.

Problem: I want to receive answers from two different stages of testing, each in different test cases, in two diff projects, but in the same workspace. Got it? great!

DECISION:

Variables for the first project

 String firstProjName = "Generic Project One" String firstProjTestSuiteName= "Generic Test Suite Name One" String firstProjTestCaseName = "Generic Test Case Name One" String firstProjTestStepName= "Generic Test Step Name One" 

Variables for the second project

 String secondProjName= "Generic Project Two" String secondProjTestSuiteName = "Generic Test Suite Name Two" String secondProjTestCaseName= "Generic Test Case Name Two" String secondProjTestStepName= "Generic Test Step Name Two" 

Standard Step Testing Access Name

 def firstProj= null def workspace = testRunner.testCase.testSuite.project.getWorkspace(); firstProj= workspace.getProjectByName(firstProjName) def firstTestCase = firstProj.testSuites[firstProjTestSuiteName].testCases[firstProjTestCaseName ] def firstTestStep = firstTestCase.getTestStepByName(firstProjTestStepName) 

Run the general test step Name One

 def runner = null runner = firstTestStep.run(testRunner, context) def firstTestStepResp = runner.getResponseContent() runner = null 

Print response to the magazine

 log.info(firstTestStepResp) 

The same with the second stage of testing

 def secondProj= null secondProj= workspace.getProjectByName(secondProjName) def secondTestCase = secondProj.testSuites[secondProjTestSuiteName ].testCases[secondProjTestCaseName] def secondTestStep = secondTestCase.getTestStepByName(secondProjTestStepName) runner = secondTestStep.run(testRunner, context) def secondTestStepResp = runner.getResponseContent() log.info(secondTestStepResp) 

Now we have access to both answers as strings with which we can play, but we want. Compare, tokenize, etc. There is also

 getResponseContentAsXml() 

if response is required as xml instead of string.

+1
source share

All Articles