RESTFul Webservice 接口测试教程和演示代码
Rest-Assured 是一个测试 Restful Web Service 的 Java 类库,我们能够测试各种各样的请求组合,依次测试核心业务逻辑的不同组合。Rest-Assured 库提供了验证从服器收到的 HTTP 响应的功能。我们可以很方便验证状态码,状态信息,标题和响应的正文。同时我们可以把 Rest-Assured 集成到 Junit 或 TestNG 测试框架中,也可以集成到 Cucumber 等 BDD(Behavior Driven Development)敏捷测试框架中。
本 Chat 以实际应用为主题,包含的内容有:
- 测试环境搭建;
- 使用 Rest-Assured 发送 Get 请求;
- 使用 Rest-Assured 验证返回状态;
- 使用 Rest-Assured 验证报文头;
- 使用 Rest-Assured 验证报文内容;
- 使用 Rest-Assured 发送 Post 请求;
- 把 JSON 格式数据封装为 Java 类;
- RESTFul Webservice 中的验证和授权。