Groovy Script and Property transfer in soapUI

2020-05-02 11:41发布

Is there any way in which I can run a Property Transfer step from a groovy script? Both are in the same test case.

Test case contains the following test steps:

  1. groovy script
  2. soapUI request (GetAccountNumber)
  3. property transfer step (transfers a response property from above to a request property in the below step)
  4. soapUI request (DownloadURL)

I need to make sure that the flow is as follows:

  1. Groovy runs and reads numbers from a file and passes them to GetAccountNumber.
  2. GetAccountNumber runs with the passed values and generates a response.
  3. This response is passed by the property transfer step to DownloadURL.
  4. DownloadURL runs with this passed value and generates an output.

All I need to do is run the Property Transfer from the groovy because the other steps can be run from groovy.

It isn't running with the following code

def testStep_1 = testRunner.testCase.getTestStepByName("PropertyTransfer") 
def tCase_1 = testRunner.testCase.testSuite.testCases["SubmitGenerateReport"] 
def tStep_1 = tCase.testSteps["PropertyTransfer"] 
tStep_1.run(testRunner, context)

标签: groovy soapui
1条回答
一夜七次
2楼-- · 2020-05-02 12:03

Without more context I think that your problem is a simple typo, you get your testCase and assing to tCase_1:

def tCase_1 = testRunner.testCase.testSuite.testCases["SubmitGenerateReport"];

However then to get the tStep_1 you use tCase instead of tCase_1:

def tStep_1 = tCase.testSteps["PropertyTransfer"]; tStep_1.run(testRunner, context);

Additionally if the testStep you want to run from groovy are in the same testCase you're executing; you can run it simply using:

testRunner.runTestStepByName('some teststep name')

Which I think it's more convenient than get the testStep from the testCase and then run it.

Hope it helps,

查看更多
登录 后发表回答