katalon 测试用例用变量参数化 [英] katalon test case parameterize with variable
问题描述
每次运行测试用例时,我都希望发布不同的 API 主体.
i would like post different API body every time the test case run.
我已经在 POST 对象中设置了变量例如testID 默认值 test0001然后 HTTP 正文如下,测试和验证通过.{drugId": $testID",}
i have set the variable at POST object e.g. testID default value test0001 then the HTTP body as below, test and verify passed. { "drugId": "$testID", }
我可以在测试用例中使用什么语法/命令,比如参数化测试步骤,所以第一次运行测试用例药物 ID = test0001第二次运行测试用例,它将是药物 ID = test0002
what syntax/command i can use in test case like parameterize test step, so first time test case run drugId = test0001 second time test case run, it will be drugId = test0002
推荐答案
您的 HTTP 正文应该类似于
Your HTTP body should be something like
{
"drugId": "${testID}"
}
你在代码中的请求应该是这样的
And your request in code should look something like this
response = WS.sendRequest(findTestObject('requestObject',[('testID'): 'test0001']))
其中 requestObject
是您保存在对象存储库中的请求.
where requestObject
is your request saved in the Object Repository.
实施
现在,如果你想迭代 10 次,你可以执行以下操作:
Now, if you want to iterate this 10 times, you can do the following:
- 使用以下内容创建一个名为callee"的新测试用例
response = WS.sendRequest(findTestObject('requestObject',[('testID'): testID]))
- 使用以下内容创建另一个名为caller"的测试用例
String test = "test000"
for(i=0;i<10;i++){
WebUI.callTestCase(findTestCase("callee"), ["testID":"${test+i.toString()}"], FailureHandling.OPTIONAL)
}
- 运行调用者"测试
这篇关于katalon 测试用例用变量参数化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!