Questions tagged [rest-assured]

REST Assured is a Java library that provides a domain-specific language (DSL) for writing powerful, maintainable tests for RESTful APIs.

REST Assured enables testing of REST services in Java.

It uses a fluid syntax inspired by similar libraries for and .

2207 questions
22
votes
3 answers

What's the difference between MockMvc, RestAssured, and TestRestTemplate?

For all I know, MockMvc is just testing the Controller, and mocking the Service layer. Whilst RestAssured and TestRestTemplate are testing the running instance of our API. Is that correct? And what's the difference between RestAssured and Spring…
Silly Sally
  • 1,027
  • 2
  • 10
  • 15
21
votes
11 answers

How to make HTTPS GET call with certificate in Rest-Assured java

How can I make a GET call using Rest-Assured in java to a endpoint which requires certificate. I have certificate as .pem format. In PEM file there is certificate and private key.
rohitkadam19
  • 1,734
  • 5
  • 21
  • 39
21
votes
8 answers

setting content type in rest assured

I'm trying to invoke a rest call using rest assured. My API accepts, "application/json" as content type and I need to set in the call. I set the content type as mentioned below. Option 1 Response resp1 =…
TechRookie
  • 211
  • 1
  • 2
  • 7
19
votes
6 answers

How do we pass multiple headers in rest assured?

I am new to rest-assured and Java, I am trying to do a very basic test of checking the response is 200 ok for API. can you any one please tell me what do I need to change in the below script in order to pass multiple headers Id, Key and…
Jatinder Pal Singh
  • 331
  • 1
  • 3
  • 9
19
votes
3 answers

Tool for testing RESTful Web services

I am trying to evaluate the right tool to test RESTful Web services and eventually automate the same for our project. Wondering, what are the specifications I need to look for such test, when i compare various tools on internet. Definitely, one of…
user2640248
  • 393
  • 1
  • 4
  • 14
18
votes
4 answers

How to verify that array contains object with rest assured?

For example, I have JSON in response: [{"id":1,"name":"text"},{"id":2,"name":"text"}]} I want to verify if a response contains a custom object. For example: Person(id=1, name=text) I found solution: Person[] persons =…
Yaryna
  • 340
  • 1
  • 5
  • 11
17
votes
2 answers

Rest Assured: JSON path body doesn't match doubles

I'm trying to test a API with Rest Assured. There is an AssertionError when I'm checking a double value. The code for checking the double: given().body(getTest()).contentType("application/json\r\n"). when() .port(port) …
476rick
  • 2,764
  • 4
  • 29
  • 49
16
votes
8 answers

Getting java.lang.AbstractMethodError when I test using REST Assured

I'm trying to test a REST api defined in my controller class using REST Assured v4.3.0, but I get java.lang.AbstractMethodError when I run the test. I understand this error is occurring because I'm calling an abstract method, but I'm having a hard…
pgngp
  • 1,552
  • 5
  • 16
  • 26
16
votes
2 answers

RestFuse vs Rest Assured vs MockMVC Rest Service Unit Test Framework

I've been trying to find a simple all purpose unit test framework for Spring MVC based Rest Services I've written. I've been searching online and narrowed it down to: RestFuse (http://developer.eclipsesource.com/restfuse/) Rest Assured…
JackDev
  • 11,003
  • 12
  • 51
  • 68
16
votes
4 answers

Log restassured traffic

I'd like to know if there is a way of logging all the calls and responses (url + payload) processed by restassured. THe finality would be to have a "debug" test log with all the calls and traffic logged. Of course I could issue calls to the logger…
devlearn
  • 1,725
  • 2
  • 17
  • 30
15
votes
6 answers

How to pass parameters to Rest-Assured

Can someone help me in this scenario: When I invoke this service, http://restcountries.eu/rest/v1/, I get couple of countries information. But when I want to get any specific country information like say Finland, I invoke the web service as…
Uday
  • 1,433
  • 10
  • 36
  • 57
14
votes
2 answers

How to pass authorization token in header in Rest assured?

Trying to automate api testing using Rest assured @Test public void Login() { Response resp = given(). body("{\"phone_number\":\"2222222222\",\"\r\n" + " + \" \"country_code\": \"+91\",\"\r\n" + …
Bharath S
  • 163
  • 1
  • 3
  • 6
14
votes
3 answers

POST request fails (rest-assured test)

I have problem with making POST request with rest-assured. This code works: given().contentType(ContentType.JSON).body("{\"key\": \"val\"}"). when().post(url + resource).then().assertThat().statusCode(200).body("otherVal",…
Purple
  • 711
  • 2
  • 10
  • 19
14
votes
4 answers

Rest Assured - can't POST with Parameters and Body

I'm testing a REST api using Rest Assured. I'm running into an error when trying to POST with both a parameter in the url and body content. This works correctly when testing manually. Removing the parameter form the url is not an option Test…
Jake Walsh
  • 3,669
  • 5
  • 22
  • 28
13
votes
2 answers

Print response body when statusCode assert fails with restassured

I'm using Hamcrest to unit test a REST API. When I send a request, I often check for a 200 status code like this : public void myTest() { url = "route/to/my/rest/api/"; secured().when().get(url).then().statusCode(200); } But when I get a…
Matthias Beaupère
  • 1,731
  • 2
  • 17
  • 44