then() 方法在 REST-assured 中有什么作用?

What does the then() method do in REST-assured?

我正在寻找 then() 方法在 REST-assured API 中的作用的正式定义,但在 javadoc 中找不到方法解释。它有什么作用?

参考: http://static.javadoc.io/io.rest-assured/rest-assured/3.0.7/io/restassured/RestAssured.html

获取returns一个Response对象:http://static.javadoc.io/io.rest-assured/rest-assured/3.0.7/io/restassured/response/Response.html

Response继承了以下接口:ResponseBody、ResponseBodyData、ResponseBodyExtractionOptions、ResponseOptions、Validatable

then 是唯一的 Validatable 方法:http://static.javadoc.io/io.rest-assured/rest-assured/3.0.7/io/restassured/response/Validatable.html

但是,这通过使用 ValidatableResponseOptions 驱动了大多数事件驱动的验证:http://static.javadoc.io/io.rest-assured/rest-assured/3.0.7/io/restassured/response/ValidatableResponseOptions.html

在测试中 class,这允许您编写专门用于验证您的其余端点的测试,而不必对 RestResponse 进行相对更混乱的拆包来评估响应的各个部分。