霍格沃兹测试开发
ceshiren.com
官网地址: http://rest-assured.io/
xml/json
的结构化解析xpath/jsonpath/gpath
解析方式 {style=zoom:30%}
TestRestAssured.java
fun
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
public class TestRestAssured {
@Test
void fun(){
given()
// given 设置测试预设(请求头、请求参数、请求体等等)
.header("Hello", "Hogwarts")
.when()
// when 所要执行的请求动作
.get("https://httpbin.ceshiren.com/get")
.then()
// then 解析结果、断言
.log().all(); // 打印全部响应信息(响应头、响应体、状态等等)
}
}
JUnit5
依赖配置pom.xml
中添加配置信息<!-- JUnit5 -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>