rest-assured

如何选择API测试工具

爱⌒轻易说出口 提交于 2020-01-07 03:51:14
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 没有最好,只有最合适。 如今,越来越多的公司正在向DevOps的方向左转,以实现持续集成和持续部署开发。这意味着我们的反馈需要比以往更快,以便确定我们的应用程序是否准备好交付。这就是API测试如此重要的原因,以及为什么应将其作为整体自动化策略重要的一部分。 分享一下我认为不错的五种API测试工具,无论哪种方式,它们都是不错的选择。 Rest-Assured 如果您使用的是Java,则Rest-Assured将是实现API自动化的首选。 Rest-assured是一个流行的Java库,可用于测试基于HTTP的REST服务。它在设计时就考虑到了测试,并且与任何现有的基于Java的自动化框架集成在一起。它提供了一个类似于BDD的DSL,从而使用Java创建API测试变得简单。它还具有许多内置功能,这意味着不必从头开始编写代码。Rest-assured可以和很多测试框架无缝集成,这意味着可以将UI和API测试全部结合在一个框架中,从而生成全面出色的报告。与动态语言(例如Ruby和Groovy)相比,用Java测试和验证REST服务要困难得多。这是使用REST-Assured的另一个原因,因为它将Java语言中使用这些语言的简便性带给了您。 如果团队主要由Java开发人员组成,对API测试来说Rest

Accessing objects within nested loops using hashmap List

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-05 04:23:06
问题 I have a JSON response which I want to parse and extract the data from. Here is the JSON response [ { "od_pair":"7015400:8727100", "buckets":[ { "bucket":"C00", "original":2, "available":2 }, { "bucket":"A01", "original":76, "available":0 }, { "bucket":"B01", "original":672, "available":480 } ] }, { "od_pair":"7015400:8814001", "buckets":[ { "bucket":"C00", "original":2, "available":2 }, { "bucket":"A01", "original":40, "available":40 }, { "bucket":"B01", "original":672, "available":672 }, {

How to resolve java.lang.java.lang.NoSuchFieldError:DEF_CONTENT_CHARSET in rest assured?

北城余情 提交于 2020-01-04 05:36:23
问题 I am a beginner, and am trying to check response for given url. I have written a very simple code, but am recieving an exception. I have tried a lot of things, but I have not been able to resolve it. Please help me. Code: public class RestAPITest { @Test public void test() { final String url = "http//:127.0.0.1:8080/myproject/api/"; given().parameter("HEADER_NAME", "X-Auth-Token", "MY_DEFAULT_TOKEN", "_MY_REST_TOKEN"). contentType("application/json; charset=UTF-16").when().get(url).then()

Groovy Rest-Assured missing method exception for ArrayList

人盡茶涼 提交于 2020-01-03 03:07:39
问题 I'm using IntelliJ here and I'm getting a missing method exception that I can't figure out in this Groovy implementation of RestAssured. The suspect method is this: when().get("http://jsonplaceholder.typicode.com/posts/1") .then().body("id", equalTo(1)) I get the following exception: Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.toSorted() is applicable for argument types: (io.restassured.internal.RequestSpecificationImpl$

How can I solve error on then(). in Rest API

旧时模样 提交于 2019-12-31 06:58:27
问题 lease review below Code: package API_Testing; import io.restassured.RestAssured; import static io.restassured.RestAssured.given; public class FirstAPIClass { public static void main(String[] args) { RestAssured.baseURI="http://localhost:5100"; given(). header("tenantId","Augusta-PT"). when(). get("/WorkExperience"); then().assertThat().statusCode(200); } } Error on then statement: The method then() is undefined for the type FirstAPIClass Also, Can i write the code without then, If i dont have

testing spring boot rest application with restAssured

坚强是说给别人听的谎言 提交于 2019-12-30 02:51:04
问题 I've been struggling with this for some time now. I'd like to use restAssured to test my SpringBoot REST application. While it looks like container spins up properly, rest assured (and anything else seems to have problems reaching out to it. All the time I'm getting Connection refused exception. java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net

How to search/find In JSON with java

天涯浪子 提交于 2019-12-28 06:06:01
问题 I have a below JSON string from the below i want to find/search criteria in JSON String. 1). To find the Number of keys present. 2). To get the values of given key(if we have array) { "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95 }, { "category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99 }, { "category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553

Dealing arrays with hamcrest and rest assured

爱⌒轻易说出口 提交于 2019-12-25 14:27:40
问题 I can't figure out how to create the code using hamcrest to check an array inside array having these properties. (Imagine this as it has multiple entries with different data) { "mobilenum": "+6519829340", "firstname": "Allen", "lastname": "Edwards", "location": "Singapore" } If I use this: .body("smsentries.mobilenum", contains(equalTo("+6519829340"))); it returns that it does exist but how can I put more checks that the object it has found also has the same firstname, lastname and location?

REST Assured - org.apache.http.NoHttpResponseException: <server_address>:80 failed to respond

泄露秘密 提交于 2019-12-25 09:29:33
问题 I'm facing this issue with REST Assured 3.0.3 intermittently, and the corresponding line of code is in a for loop. It is a simple GET call like mentioned below: response = given().setBaseUri(someBaseUri).setBasePath(someEndPoint).param("key", "value").header("X-Authorization-Token", my_auth_token).get(); I found a couple of StackOverflow answers suggesting to resolve the issue using ConnectionConfig , but I don't know how to resolve the issue while using REST Assured. Below is the full trace:

RestAssured Post call with nested object throws an error “java.lang.AssertionError: 1 expectation failed. Expected status code <200> but was <500>.”

隐身守侯 提交于 2019-12-25 00:57:07
问题 @Test public void testPost() throws URISyntaxException { DbConnectionProperties sourceDB = new DbConnectionProperties("SourceDBName", "SourceDBDriver", "SourceDBUrl", "SourceDBUserName", "SourceDBPassword"); DbConnectionProperties destinationDB = new DbConnectionProperties("DestinationDBName", "DestinationDBDriver", "DestinationDBUrl", "DestinationDBUserName", "DestinationDBPassword"); Streams streamsAvailablity = new Streams(1, 1, 1, 1); AgencyRequest agencyRequest = new AgencyRequest();