Web Services- Data-driven testing

I tried looking and could find a straight forward answer anywhere.

So here are the steps:

  1. Set up a post request and link one of the property in request to a globalVariable created under variable section of the post request
  2. Create a test case with “Send request and verify” this post request
  3. In the body of WS.sendRequestAndVerify(findTestObject…), it will automatically show the property tied to globalVariable
  4. Now I create another local variable in test case, my question is how do I link this local variable with that global Variable? or do I remove that globalVariable in the reference made under WS.sendRequestAndVerify(findTestObject…) and link local variable there? If so how, what format

E.g:
some post request create api with body:
{
.
.
“{application}”:"${app}"
.
.
}

declared under post request variable, app : globalVariable.app

Now in test case it will show:
WS.sendRequestAndVerify(findTestObject(some create api, , [(‘app’) : GlobalVariable.app…])

since I am trying to run test case under test suite with data set, I have to define local variable in test case which maps to ‘app’. Lets say i declare it with the same name under variable, so do i enter ${app} instead of GlobalVariable.app in the body above? This doesn’t seem to work.

How are variables linked between request and test case?
Is there a order of precedence which code checks to pick a variable?

Thanks

Hi there,

You can do it like this, assuming that tcVariable is a test case variable

tcVariable = 
WS.sendRequestAndVerify(findTestObject(some create api, , [(‘app’) : tcVariable])

Which will pass the value of tcVariable into the request. Is this what you want ? I am kinda confused since you mentioned that

Which I take it that you’re using Data Driven testing from external data. So what do you use a global variable for in this case ?

Thanks Thanh. For local testcase variable do I define it like this ?.. [(‘app’) : ${tcVariable}])…
Do i need to remove globalVariable link in the request, for some reason it is always picking the globalVariable value instead of picking from the external data linked in test suite.

Nevermind, it did pick up when local variable was linked properly. Thanks

1 Like