katalon test case parameterize with variable

天大地大妈咪最大 提交于 2020-04-30 15:46:17

问题


i would like post different API body every time the test case run.

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”, }

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


回答1:


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']))

where requestObject is your request saved in the Object Repository.

Implementation

Now, if you want to iterate this 10 times, you can do the following:

  1. create a new test case called "callee" with the following content
response = WS.sendRequest(findTestObject('requestObject',[('testID'): testID]))
  1. create another test case called "caller" with the following content
String test = "test000"
for(i=0;i<10;i++){
    WebUI.callTestCase(findTestCase("callee"), ["testID":"${test+i.toString()}"], FailureHandling.OPTIONAL)
}
  1. run the "caller" test


来源:https://stackoverflow.com/questions/57798753/katalon-test-case-parameterize-with-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!