REST-assured

码农软件 · 软件分类 · REST/RESTful项目 · 2019-03-10 20:28:53

软件介绍

用于方便REST服务测试的JAVA DSL

举例如下:

Here's an example of how to make a GET request and validate the JSON or XML response:

get("/lotto").then().assertThat().body("lotto.lottoId", equalTo(5));

Get and verify all winner ids:

get("/lotto").then().assertThat().body("lotto.winners.winnerId", hasItems(23, 54));

Using parameters:

given(). param("key1", "value1"). param("key2", "value2"). when(). post("/somewhere"). then(). body(containsString("OK"));

Using X-Path (XML only):

given(). parameters("firstName", "John", "lastName", "Doe"). when(). post("/greetMe"). then(). body(hasXPath("/greeting/firstName[text()='John']")).

Need authentication? REST Assured provides several authentication mechanisms:

given().auth().basic(username, password).when().get("/secured").then().statusCode(200);

Getting and parsing a response body:

// Example with JsonPath 
String json = get("/lotto").asString() 
List<String> winnderIds = from(json).get("lotto.winners.winnerId"); 
// Example with XmlPath 
String xml = post("/shopping").andReturn().body().asString() 
Node category = from(xml).get("shopping.category[0]");

REST Assured supports the POST, GET, PUT, DELETE, OPTIONS, PATCH and HEAD http methods and includes specifying and validating e.g. parameters, headers, cookies and body easily.

本文地址:https://codercto.com/soft/d/1067.html

关乎天下

关乎天下

关明生 / 学林出版社 / 2005-8 / 8.00元

《关乎天下:中小企业赢取江山的秘诀》收录了作者多年在大企业(如阿里巴巴网站)从事管理基层得到的经验,可为众多中小企业提供招贤纳士和销售管理方面的新思路。一起来看看 《关乎天下》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

URL 编码/解码
URL 编码/解码

URL 编码/解码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具