概述
REST Assured支持发起POST,GET,PUT,DELETE,OPTIONS,PATCH和HEAD请求,并且可以获取和验证请求的响应信息
本系列文章主要是要构建一个 基于 Rest Assured + TestNG 的自动化测试框架
功能
- 使用RestAssured进行接口测试
- 使用RestAssured封装底层接口驱动
官网
Maven依赖
//Rest-assured
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.2.0</version>
</dependency>
//Stand-alone XmlPath (included if you depend on the rest-assured artifact). Makes it easy to parse XML documents.
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>xml-path</artifactId>
<version>4.2.0</version>
</dependency>
//Standalone JsonPath (included if you depend on the rest-assured artifact). Makes it easy to parse JSON documents.
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
<version>4.2.0</version>
</dependency>
//If you're using Spring Mvc you can now unit test your controllers using the RestAssuredMockMvc API in the spring-mock-mvc module. For this to work you need to depend on the spring-mock-mvc module:
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>spring-mock-mvc</artifactId>
<version>4.2.0</version>
</dependency>
//If you're using Spring Webflux you can now unit test your reactive controllers using the RestAssuredWebTestClient API in the spring-mock-mvc module. For this to work you need to depend on the spring-web-test-client module:
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>spring-web-test-client</artifactId>
<version>4.3.3</version>
<scope>test</scope>
</dependency>
//json schema
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>4.2.0</version>
</dependency>
参考
https://github.com/rest-assured/rest-assured/wiki/GettingStarted
版权所有,本文为原创文章,转载请注明出处