本篇学习的path parameters和Headers和Cookies的设置。
1.Path Parameters
还是介绍如何设置在请求的Url中的参数使用。这个path parameters就是先用变量去表示key,然后通过函数pathParam()给key设置value,最后在请求的url中,用变量名称拼接在整个完整的请求URL。
下面是一个模板方法。
/**
* path parameters type1
*/
@Test
public void testPataParametersType1() {
given().
pathParam("type","json").
pathParam("section","Domains").
when().
get("https://xxxx/api/{type}/{section}/").
then().
statusCode(400);
}
上面是一个模板方法,不能跑起来,我们找一个实际例子来测试下
@Test
public void testPataParametersType1() {
given().
pathParam("section","posts").
pathParam("id","3").
when().
get("http://jsonplaceholder.typicode.com/{section}/{id}").
then()