问题
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:
- groovy script
- soapUI request (GetAccountNumber)
- property transfer step (transfers a response property from above to a request property in the below step)
- soapUI request (DownloadURL)
I need to make sure that the flow is as follows:
- Groovy runs and reads numbers from a file and passes them to GetAccountNumber.
- GetAccountNumber runs with the passed values and generates a response.
- This response is passed by the property transfer step to DownloadURL.
- 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)
回答1:
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,
来源:https://stackoverflow.com/questions/35497480/groovy-script-and-property-transfer-in-soapui