问题
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:
- create a new test case called "callee" with the following content
response = WS.sendRequest(findTestObject('requestObject',[('testID'): testID]))
- 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)
}
- run the "caller" test
来源:https://stackoverflow.com/questions/57798753/katalon-test-case-parameterize-with-variable