REST-assured 方便 REST 服务测试的 JAVA DSL开源项目

我要开发同款
匿名用户2016年02月04日
80阅读

技术信息

开源地址
https://github.com/jayway/rest-assured
授权协议
Apache

作品详情

REST-assured用于方便REST服务测试的JAVADSL。

举例如下:

Here'saexampleofhowtomakeaGETrequestadvalidatetheJSONorXMLrespose:

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

Getadverifyallwierids:

get("/lotto").the().assertThat().body("lotto.wiers.wierId", hasItems(23, 54));

Usigparameters:

give(). param("key1", "value1"). param("key2", "value2"). whe(). post("/somewhere"). the(). body(cotaisStrig("OK"));

UsigX-Path(XMLoly):

give(). parameters("firstName", "Joh", "lastName", "Doe"). whe(). post("/greetMe"). the(). body(hasXPath("/greetig/firstName[text()='Joh']")).

Needautheticatio?RESTAssuredprovidesseveralautheticatiomechaisms:

give().auth().basic(userame, password).whe().get("/secured").the().statusCode(200);

Gettigadparsigaresposebody:

// Example with JsoPath Strig jso = get("/lotto").asStrig() List<Strig> widerIds = from(jso).get("lotto.wiers.wierId"); // Example with XmlPath Strig xml = post("/shoppig").adRetur().body().asStrig() Node category = from(xml).get("shoppig.category[0]");

RESTAssured支持任何HTTP方法,但显式支持POST,GET,PUT,DELETE,OPTIONS,PATCH和HEAD,并且包括轻松指定和验证参数,标头,cookie和主体。

功能介绍

REST-assured 用于方便 REST 服务测试的 JAVA DSL。 举例如下: Here's an example of how to make a GET request and v...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论