例如,您可以使用workspace https://www.soapui.org/apidocs/com/eviware/soapui/model/workspace/Workspace.html属性来访问当前项目中的其他项目,以从中获取属性。您可以通过绝妙的脚本.
在第一个项目中添加一个Groovy 脚本测试步骤在你的testCase并将属性设置为项目级别如下:
testRunner.testCase.testSuite.project.setPropertyValue('myProp','myValue')
在第二个项目中添加另一个绝妙的脚本 in the testCase通过以下方式获得您的财产的价值workspace
并分配到您想要的级别(例如在测试套件,但您可以在需要的地方添加):
// get the other project
def otherProject = testRunner.testCase.testSuite.project.workspace.getProjectByName('SecondProjectName')
// get your property value
def value = otherProject.getPropertyValue('myProp')
log.info value
// set the var at some level in this case in testSuite
testRunner.testCase.testSuite.setPropertyValue('varFromOtherProject',value)
然后使用该变量testStep使用以下符号的第二个项目:
${#TestSuite#varFromOtherProject}
UPDATE:
似乎您正在使用单独运行您的项目测试运行者因此您无法使用访问其他项目workspace
,因此作为一种可能的解决方法,您可以将属性值写入File在你的第一个项目中,然后阅读File您的第二个项目中的内容。
所以在你的第一个项目 add a Groovy 脚本测试步骤使用以下代码:
new File('./myProp').text = 'someValue'
然后在你的第二个项目阅读File并将属性设置为某个测试级别:
// get the value from the file
def value = new File('./myProp').text
log.info value
// set the var at some level in this case in testSuite
testRunner.testCase.testSuite.setPropertyValue('varFromOtherProject',value)
正如之前所解释的,在您的中使用以下符号SOAP测试步骤获得财产:
${#TestSuite#varFromOtherProject}
希望能帮助到你,