添加maven坐标
<dependencies>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
demo
//given开头表示输入数据
given().log().all()
//query请求参数
.queryParam("code", "sogo")
//头信息
.header("Cookie","_ga=GA1.2.506579530.1552574503; device_id=0158c91c7ecd8e4d248a54002af6d8ae; aliyungf_tc=AQAAAIatGzFrQgoAJGDMeOsikkxtPFqv; xq_a_token=682c39a460645dafb1ff41f67e0efccba8b0f118; xq_a_token.sig=Bg9acTC-woVSsS6DZvdAtd40CQU; xq_r_token=798a7cab8cd606f61a09fbac15374f1172b00607; xq_r_token.sig=sHSWFNmu_GqEUOK9A-6umfNgFcU; _gid=GA1.2.841306833.1553178554; Hm_lvt_1db88642e346389874251b5a1eded6e3=1552574504,1552736056,1553178554; u=881553178554746; _gat=1; Hm_lpvt_1db88642e346389874251b5a1eded6e3=1553180196")
//when表示触发条件
.when()
.get("https://xueqiu.com/stock/search.json")
//then对结果断言
.then()
//打印log
.log().all()
//断言状态码
.statusCode(200)
//字段断言
.body("stocks.name",hasItems("搜狗"))
.body("stocks.code",hasItems("sogo"));