4

Here's a number of design patterns you can use for testing REST services (with REST-assured, but not necessarily*): Service Object pattern. Just like Page Object encapsulates HTML page, Service Object encapsulates REST API. Hence, instead of dealing directly with forming HTTP requests and parsing HTTP responses, you can use business level methods like ...


4

A few thoughts: Automation code should be reviewed, so I don't think that's a con Not sure why failing test cases would keep your build from compiling. Even if the test code lives in the same repo as the application code, your build scripts should ignore the test code when compiling deliverable code. There might be a failure further down your build chain ...


3

You just get Response object from your call and do: public class Test { public static void main(String[] args) { Response response = RestAssured .get("https://mocki.io/v1/22617277-2eca-4fcf-b7e2-8c80851ef45d"); if(response.path("shop.type") == null){ System.out.println("key does not ...


3

make sure you are importing org.testng.annotations.Test and not org.junit.Test


3

https://www.postman.com/explore it have many collections and examples, you can create a account and fork it and use. or create your own mock server here and learn: https://app.mocklab.io/


3

As with any project, it depends :). That said, (1) and (2) require close coordination with development team. Depending on the team structure it may be a good thing or a bad thing :). I also suspect in both cases some code will have same development (unit) tests as your tests. For example, a DTO might have a bug which may not be caught by both the teams. (3) ...


3

Don't focus too much on tooling. Tools will go out of fashion. Perhaps not this year, not in 2 years, but definitely a few times during your career life (provided you are not at the end of it, but have, say, 5+ year ahead). Here are some points along which you might want to explore: what an API is and what we're trying to achieve with it what problems web ...


2

Now take a look at setFormParam() method: System.out.println(reqSpec);// reqSpec Always getting null value reqSpec.formParam(keyValue[0], keyValue[1]); and then at postCandidateResponse() that calls setFormParam(): public static Response postCandidateResponse(Hashtable<String, String> data) { requestSpec= TestUtils.setFormParam(data.get("...


2

What you show is actually a response body. Headers are represented in "Headers" tab in Dev Tools like this: Brief look up of what you provided shows that it's UTF-16 encoded string: For example: 1 - BATAK LETTER CA 2 - MANDAIC LETTER ATT 3 - http://www.fileformat.info/info/unicode/char/41bc/browsertest.htm no dedicated name


2

Example json: { "priceOne": 1034, "priceTwo": {"new":2}, "priceThree": 7282 } Checking the value of "new" Response response =RestAssured.get("https://newnnnnnnn.free.beeceptor.com"). then().extract().response(); JSONObject jsonObj = ...


2

The file path should be relative to class path , try statusCode(200).and().body(matchesJsonSchemaInClasspath("\\test\\java\\com\\rest\\api\\schema\\getuserschema.json")); or statusCode(200).and().body(matchesJsonSchemaInClasspath(".\\test\\java\\com\\rest\\api\\schema\\getuserschema.json")); or statusCode(200).and().body(...


2

Which approach or should I say framework is better? I don't think you can compare them just like that when you don't mention any context, any goals you might have, what you want to achieve with the tool, how big your project is, who is on the team, and many more. Which are let say 3 facts you should consider when making final decision? Some things I'd ...


2

https://jsonplaceholder.typicode.com/ {JSON} Free fake API for testing and prototyping. Powered by JSON Server + LowDB As of Dec 2020, serving ~1.8 billion requests each month.


2

As this answer on Stackoverflow states. https://httpbin.org/ allows you to echo back your request, to see that it does what you expect. this is the list of services It echoes the data used in your request for any of these types: https://httpbin.org/anything Returns most of the below. https://httpbin.org/ip Returns Origin IP. https://httpbin.org/user-agent ...


2

You can blacklist the headers you don't want to see in the report: given().config(config().logConfig(logConfig().blacklistHeader("Accept"))). .. Documentation here.


1

String response =RestAssured.get("https://praveendvd.free.beeceptor.com/test"). then().extract().response().asString(); JSONObject jsonObj = new JSONObject(response); int val = (jsonObj.isNull("priceTwo")) ? 2:jsonObj.get("priceTwo"); vehicle.setPrice(val); you can directly pass without ...


1

You can use Hamcrest matchers to verify that: package click.webelement.api.restassured; import io.restassured.RestAssured; import java.net.MalformedURLException; import java.net.URL; import static org.hamcrest.Matchers.*; public class ValueValidation { public static void main(String[] args) throws MalformedURLException { RestAssured ...


1

Looking at that stracktrace, the regular expression used for the matching is recursing infinitely causing a stackoverflow exception. Your search criteria is likely being translated into a regex without properly formatting your search criteria first. Have a look if there is a \ or * in your searchcriteria and whether you need it.


1

Check if you have correct sheet name. As you can see in stacktrace, error happens in ExcelUtil line 27. Debug/Print the sheet name to see if the value is correct.


1

The Problem is with scope of the Rest Assured dependency in the pom.xml file If your running your Rest Assured test from src/main/java the scope should be compile and your dependency will be as shown below <dependency> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <version>3.0.2</...


1

Why you are initializing the AppMethods ApiMethods inside the testclass constrcutor this is not right way testng works only with the class which has constructor with no arguments You can use @BeforeTest for intilizing the classes so that your testclass.java will be as shown below public class TestClass extends Base { public AppMethods appObj; ...


1

JsonPath that is used in RestAssured uses the different syntax. Your path would look like cust.findAll{i -> i.name == 'STATUS_ID' || i.name == 'RENEWAL_ID'}.id. Here is the example code: package click.webelement.api.restassured; import io.restassured.path.json.JsonPath; import java.util.List; public class ExtractList { static final String JSON = &...


1

Here is the example that addresses your particular problem: package click.webelement.api.restassured; import io.restassured.path.json.JsonPath; import java.util.HashMap; import java.util.List; public class KeyValidation { static final String JSON = "[\n" + " {\n" + " \"id_\": \"123\",\n" + " \"...


1

I am not sure what you are trying to do, your code fails because public String urlBuilder(String url, Map<String, String> queryParam) In the parameter definition, you type casts it as a Map of Map<String, String> and then you are passing a map of Map<String, ArrayList> So just changing that will fix the issue: public String urlBuilder(...


1

What you are showing is called a JSON object. Unless you're in JavaScript (that can natively parse JSON data) you can use a jsonpath language that is very similar to xpath (serves for similar purpose). Using jsonpath query you can access any JSON part (including what you're looking for). Here are few refs for different tools/languages (not neccessery related ...


1

Answering your particular question, I'd like to spotlight that there are several ways to assert headers. And ("Key","value") is one of those ways. You can also find the methods which allow you to apply matchers when you assert your headers. Why can't we use just- body("scope","APP") Any specific reason behind this? Because unlike the headers (which are ...


1

Why is this not an option? JsonPath resJson= new JsonPath(response); JsonPath referrenceJson= new JsonPath(jsonTOCompare); Assert.assertEquals(resJson.get("fields"), referrenceJson.get("fields"));


1

1 - Sure. Cucumber is a test runner. The goal of this kind of tool is only to execute a suite with certain structure is a certain way. Cucumber manages the execution of certain methods according to the matches of .feature files. Rest-assure is a library. It abstracts HTTP calls. You can add anything under Cucumber step definition methods, including ...


1

Is it a fair test? Not really. Performance tests usually involve warm-up phase as anonygoose suggested in his/her answer. For instance, in case of HTTP clients this is to let them start thread and HTTP connection pools. Performance tests should sent many requests over time. If you're sending only one request you might be simply out of lack as the server ...


1

According to this question Rest Assured is pretty slow on the first request you make. Looks like it has to warm up a little for some reason. I've tested version 4.0 of Rest Assured myself, and this appears to be the case. The first request is 2000ms+, then every subsequent request in the same suite is 200-300ms. A counter question might be: why compare ...


Only top voted, non community-wiki answers of a minimum length are eligible