TestStep.run
方法不能從其他一步步測試直接返回所需的對象或如此,它會返回一個通用WsdlTestStepResult
對象查看testStep執行的狀態,可能的錯誤等,因爲log.info Test_script.run(testRunner,myCont)
它打印toString()
方法的結果在WsdlTestStepResult
對象上。
如果你想從一個Groovy腳本一步步測試對象傳遞給另一個,你已經使用context
變量,它是在每個Groovy腳本一步步測試可用。
對於你的情況,因爲你正在運行使用TestStep.run(TestCaseRunner testRunner,TestCaseRunContext testRunContext)
從第二個劇本第一Groovy腳本,你可以回到你的第一個腳本的context
添加傳遞給run
第二個與testRunContext
對象的所有對象方法。讓我用一個例子顯示它:
在第一Groovy腳本添加你的文字作爲context
的屬性:在你的第二個腳本
// instead of log put the text in a context property
context.setProperty('somePropToGetBack','Running from different test case script')
// you can put all the properties you want...
context.setProperty('anotherOne','more props')
然後你只需要拿回這些屬性:
package com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext
def Test_script= testRunner.testCase.testSuite.project.testSuites["TestSuite"].testCases["TestCase"].testSteps["Check"]
def myCont= new WsdlTestRunContext(Test_script)
def result = Test_script.run(testRunner,myCont)
// after execution in myCont variable you've all properties you set
// in context variable of first script
log.info myCont.getProperty('somePropToGetBack') // prints Wed May 18 14:56:36 CEST 2016:INFO:Running from different test case script
log.info myCont.getProperty('anotherOne') // prints Wed May 18 14:56:36 CEST 2016:INFO:more props
希望它能幫助,
太感謝你了。我一直在尋找teststep.run概念。感謝您解釋它。 – sunny
@sunny很高興幫助你':)'。您還可以檢查['TestStepResult'](https://www.soapui.org/apidocs/com/eviware/soapui/impl/wsdl/teststeps/WsdlTestStepResult.html)中的所有可用內容,運行'方法,看看有些是你的情況。 – albciff