Forum Discussion
So to add an example:
Some REST requests are:
GET myserver.com/{ID_user}
PUT myserver.com/{ID_user}
DELETE myserver.com/{ID_user}
PATCH myserver.com/{ID_user}
POST myserver.com/{ID_user}/verify
GET myserver.com/{ID_user}/verify/{ID_number}
PUT myserver.com/{ID_user}/verify/{ID_number}
DELETE myserver.com/{ID_user}/verify/{ID_number}
I tried to make a new REST services under the Projects tab to be able to run tests from SoapUI Pro to those endpoints.
My initial thought was that I could then call these endpoints in test cases as part of a testsuite.
How can I put the {ID_user} value in the URL of a REST resource endpoint to run testcases, it seems to only accept static values and I want to look up random users without predefinding them in a list.
Tried setting up the Rest services like this:
Endpoint: Ressource: Parameters:
GET myserver.com/ {ID_user}
Or is my approach totally off? :)
If anyone has a better way to pull this off I'd love some input or another approach to dynamic URLs.
- Bill_In_Irvine8 years agoContributor
As for your second post, I would use a Groovy script and use property expansion for ID_user and ID_number.
You can get the resource in the RequestFilter.FilterRequest event handler script with
String therequestUri = new String(context.getProperty("requestUri").toString())
and sorry, you need to use string manipulation methods to work with the URL and resource.
See
It might be a matter of just appending the property expansion to the URL/resource.
Then when that is done, use the context.setProperty("requestUri") for the new path based on the property expansion for the ID_user.
Of course the expansion is done by something similar to
def ID_user = context.expand('${#Project#ID_user}')
and then you can do something like therequestUri + ID_user and that should append the user ID. But this presumes you define the user at the project level. You might find it better to define the user ID at the test case level #testCase#ID_user.
I know that this answer is not the specific solution but a start on one approach. Maybe other people have alternatives that are easier. Your project properties ID_user and ID_number might be read off of a Excel spreadsheet. I have not done this.
- Crazy_Chris8 years agoOccasional Contributor
Thank you Bill_In_Irvine,
This is a start, I will look into if your suggestions will work.
I was hoping it would be simpler way to just add to an URL but I might think in the wrong direction and just work it out through the testcase as per your suggestion.
It would be possible to just get a set of static values in an excel list to read from, but I was hoping to improve the test by getting fresh data.
- PaulMS8 years agoSuper Contributor
Template parameters are used to parametrize the request path.
https://support.smartbear.com/readyapi/docs/projects/requests/parameters/types/template.html
You can use a test suite or test case property as the input value for that parameter
Related Content
Recent Discussions
- 5 days ago
- 10 days ago