1、配置
RestAssured.baseURI = "http://...."
RestAssured.port = 8800
RestAssuredConfig RAconfig = new RestAssuredConfig();
//设置UTF-8编码
RestAssured.config = RAconfig.encoderConfig(new EncoderConfig("UTF-8", "UTF-8"));
2、POST
//map以参数名-参数值的形式
MAP map = new HashMap<String, String>();
RestAssured.given().params(map).when().post("/");
3、ASSERT
body的返回模型校验
Response resp = RestAssured.given().params(map).when().post("/");
//jsonSchema
String jsonSchema = "";
resp.then().assertThat().body(JsonSchemaValidator.matchesJsonSchema(jsonSchema));
body的字段检验(检验需要区分字段类型)
resp.then().assertThat().body("jsonPath",equalTo("hello");
resp.then().assertThat().body("jsonPath",equalTo(1);
4、反序列化
Response resp = RestAssured.given().params(map).when().post("/");
xx bean = resp.as(xx.class);