准备好了!Groovy中的API测试用例属性
刚刚开始学习ReadyApi和Groovy, 我想使用Groovy脚本将3个项目属性组合成一个属性,作为SoapUI测试中的一个步骤:准备好了!Groovy中的API测试用例属性,groovy,ui-testing,Groovy,Ui Testing,刚刚开始学习ReadyApi和Groovy, 我想使用Groovy脚本将3个项目属性组合成一个属性,作为SoapUI测试中的一个步骤: Prop1 = "\\ap52\x$" Prop2 = "\folder1\folder2\" Prop3 = "1234567890123456" 其中: Prop1是一种可以改变的净资源 Prop2是一个不太可能更改的文件夹位置 Prop3实际上是从另一个步骤生成并填充到Prop3中的随机16位数字 我需要创建PropX,以便将属性转移到文件等待步骤中
Prop1 = "\\ap52\x$"
Prop2 = "\folder1\folder2\"
Prop3 = "1234567890123456"
其中:
- Prop1是一种可以改变的净资源
- Prop2是一个不太可能更改的文件夹位置
- Prop3实际上是从另一个步骤生成并填充到Prop3中的随机16位数字
PropX = "\\ap52\x$\folder1\folder2\filename_1234567890123456_??????????.xml"
动态生成的基本环境就绪!Groovy的API测试用例属性是,和 由于脚本将动态执行,因此您不必担心底层属性值更改的上下文。因此,属性值的字符串连接是一种可行的方法 如前所述,在Groovy中实现高效字符串连接的最佳方法是避免基于Java的方法,并释放以下功能: 我自己找到的
def string1 = testRunner.testCase.testSuite.project.getPropertyValue("Prop1");
def string2 = testRunner.testCase.testSuite.project.getPropertyValue("Prop2");
def string3 = testRunner.testCase.testSuite.project.getPropertyValue("Prop3");
testRunner.testCase.testSuite.project.setPropertyValue("fileWaitLoc", string1 + string2 + "response_" + string3 + "_??????????.xml")
但是,当将此propertyvalue发送到ReadyAPI中的“等待文件”步骤时,这仍然不起作用。。。它不喜欢文件名中的通配符用法,即“???????”。
为了让文件等待步骤正常工作,我必须让开发人员删除文件名中用于唯一命名的添加字符。在我自己的def string1=testRunner.testCase.testSuite.project.getPropertyValue(“Prop1”)中找到它;def string2=testRunner.testCase.testSuite.project.getPropertyValue(“Prop2”);def string3=testRunner.testCase.testSuite.project.getPropertyValue(“Prop3”);testRunner.testCase.testSuite.project.setPropertyValue(“fileWaitLoc”,string1+string2+“response”+string3+“\u??????.xml”)请提交您的评论作为答案。自我回答是可以的。另外,作为回答,您可以使用代码格式。我不是Groovy专家,但
\“
似乎可疑。您确定它不是\\”
或/“
?为什么要在问题中添加标签?关于编码UI或用于创建和运行此类测试的Visual Studio,问题中没有任何内容。@Adrianhh我很抱歉。超出我的想象的是,一个通用的标记名将是特定工具的专有名称。我应该更仔细地阅读标签说明。我换了标签。谢谢你友好的暗示。
def string1 = testRunner.testCase.testSuite.project.getPropertyValue("Prop1");
def string2 = testRunner.testCase.testSuite.project.getPropertyValue("Prop2");
def string3 = testRunner.testCase.testSuite.project.getPropertyValue("Prop3");
testRunner.testCase.testSuite.project.setPropertyValue("fileWaitLoc", string1 + string2 + "response_" + string3 + "_??????????.xml")