To illustrate a simplified version of this scenario, consider a REST service that consists of three methods that need to be tested across three applications running on three sites :
//Site 1
//Site 1 - Application 1
http://www.site-1.com/application-1/api/GetBook
http://www.site-1.com/application-1/api/SaveBook
http://www.site-1.com/application-1/api/DeleteBook
//Site 1 - Application 2
http://www.site-1.com/application-2/api/GetBook
http://www.site-1.com/application-2/api/SaveBook
http://www.site-1.com/application-2/api/DeleteBook
//Site 1 - Application 3
http://www.site-1.com/application-3/api/GetBook
http://www.site-1.com/application-3/api/SaveBook
http://www.site-1.com/application-3/api/DeleteBook
-----
//Site 2
//Site 2 - Application 1
http://www.site-2.com/application-1/api/GetBook
http://www.site-2.com/application-1/api/SaveBook
http://www.site-2.com/application-1/api/DeleteBook
//Site 2 - Application 2
http://www.site-2.com/application-2/api/GetBook
http://www.site-2.com/application-2/api/SaveBook
http://www.site-2.com/application-2/api/DeleteBook
//Site 2 - Application 3
------
//Site 3
//Site 3 - Application 1
http://www.site-3.com/application-1/api/GetBook
http://www.site-3.com/application-1/api/SaveBook
http://www.site-3.com/application-1/api/DeleteBook
//Site 3 - Application 2
http://www.site-3.com/application-2/api/GetBook
http://www.site-3.com/application-2/api/SaveBook
http://www.site-3.com/application-2/api/DeleteBook
//Site 3 - Application 3
http://www.site-3.com/application-3/api/GetBook
http://www.site-3.com/application-3/api/SaveBook
http://www.site-3.com/application-3/api/DeleteBook
//and so on
The solution is to use a template with
parameters in the REST file for the variable parts of the URL:
"Url": "{Site}/{Application}/api/json/Method1",
...
"Parameters": [
{
"Name": "Site",
"TokenName": "{Site}",
"Value": null
},
{
"Name": "Application",
"TokenName": "{Application}",
"Value": null
}
]
For each method defined as above, the GET/POST/PUT/etc. would be defined along with additional token parameters (and default test values).
Then in the main Test js file, you need to loop over an array of sites and within this loop over an array of applications, and within this, iterate over each method name defined in saved_script_objects. That way the calls can happen and where necessary in separate test functions. Then you can override the default token values with specialized api calls specific to each method.