放心 API 测试 - 将 Json 对象作为参数传递给获取请求
Rest Assured API testing - Pass a Json Object as parameter to a get request
REST 保证测试 -
如何使用删除请求从此url
删除工作区
http://in-kumaran2-1:8080/devops-workbench-web/rest/api/workspace/delete/{projectId}
根据要求
given().when().delete(url,JSON body);
下面给出了示例请求 JSON 正文
{"name":"newworkspace","workspaceFlow":"Open
Sorce","versionControl":"SVN","featureManagement":"JIRA","defectManagement":"","buildAutomation":"Selenium","deploymentAutomation":"","buildRepository":"Nexus","codeQualityTools":"SonarQube","automatedTestingTools":"Selenium","environmentProvision":"Puppet","environmentConfiguration":"Puppet","projectId":{"id":"56cebe578850d51c6fe07684","name":"wbproject","description":"wbproject","processTemplate":"Agile","projectManager":"Anil","projectStartDate":1454284800000,"projectEndDate":1475193600000,"remarks":null,"accountId":{"id":"56cebe218850d51c6fe07683","accountName":"workbench","accountDescription":"workbench
account"}}}
projectID 有另一个对象 {"id": "56cebe578850d51c6fe07684" ....} 如何在删除请求中传递这个 projectId
实际上,我已经通过了 json object,如下所示:
Response res =given().
content(jo). //jo is the json object to pass with the url.
with().
contentType("application/json").
header("Content-Type", "application/json").
when().
post(settings.getApiUrl()); //this is the url, i use post method
jo 是这样的:
JsonObject jo = new JsonObject();
jo.addProperty("username", "abc");//key and value
jo.addProperty("password", "abc");//key and value
你可以尝试像 this.i 这样的东西在这里用作 header 你可以将它作为参数发送。
URL 是:http://example.com/building
我的查询字符串是:
globalDates:{"startMs":1473672973818,"endMs":1481448973817,"period":90}
limitTo:6
loadTvData:true
startFrom:0
userId:5834fb36981baacb6a876427
使用 Rest Assured 在 GET url 中传递查询字符串参数的方式如下:-
when().parameter("globalDates","startMs","1474260058054","endMs","1482036058051","period","90")
.参数("limitTo","6")
.参数("loadTvData","true")
.参数("startFrom","0")
.参数("userId","5834fb36981baacb6a876427");
REST 保证测试 - 如何使用删除请求从此url
删除工作区http://in-kumaran2-1:8080/devops-workbench-web/rest/api/workspace/delete/{projectId}
根据要求
given().when().delete(url,JSON body);
下面给出了示例请求 JSON 正文
{"name":"newworkspace","workspaceFlow":"Open Sorce","versionControl":"SVN","featureManagement":"JIRA","defectManagement":"","buildAutomation":"Selenium","deploymentAutomation":"","buildRepository":"Nexus","codeQualityTools":"SonarQube","automatedTestingTools":"Selenium","environmentProvision":"Puppet","environmentConfiguration":"Puppet","projectId":{"id":"56cebe578850d51c6fe07684","name":"wbproject","description":"wbproject","processTemplate":"Agile","projectManager":"Anil","projectStartDate":1454284800000,"projectEndDate":1475193600000,"remarks":null,"accountId":{"id":"56cebe218850d51c6fe07683","accountName":"workbench","accountDescription":"workbench account"}}}
projectID 有另一个对象 {"id": "56cebe578850d51c6fe07684" ....} 如何在删除请求中传递这个 projectId
实际上,我已经通过了 json object,如下所示:
Response res =given().
content(jo). //jo is the json object to pass with the url.
with().
contentType("application/json").
header("Content-Type", "application/json").
when().
post(settings.getApiUrl()); //this is the url, i use post method
jo 是这样的:
JsonObject jo = new JsonObject();
jo.addProperty("username", "abc");//key and value
jo.addProperty("password", "abc");//key and value
你可以尝试像 this.i 这样的东西在这里用作 header 你可以将它作为参数发送。
URL 是:http://example.com/building
我的查询字符串是:
globalDates:{"startMs":1473672973818,"endMs":1481448973817,"period":90} limitTo:6 loadTvData:true startFrom:0 userId:5834fb36981baacb6a876427
使用 Rest Assured 在 GET url 中传递查询字符串参数的方式如下:-
when().parameter("globalDates","startMs","1474260058054","endMs","1482036058051","period","90")
.参数("limitTo","6")
.参数("loadTvData","true")
.参数("startFrom","0")
.参数("userId","5834fb36981baacb6a876427");