Posts

Showing posts with the label functional testing

Automating POST Request using Rest Assured - Part 2

Image
In the previous post, we learned about automating a POST request by sending a string in the body method. In this post, we will focus on automating a POST request by sending an object in the body method instead of string. The reason behind sending an object in body method is that sending a string with large number of parameter can become tedious and updating a string having n number of parameters may become time consuming. Hence, it is always recommended to send an object in body method. Now lets look at an example of automating POST request using Rest Assured. public class Posts { public String id ; public String title ; public String author ; public void setId ( String id ) { this . id = id ; } public void setTitle ( String title ) { this . title = title ; } public void setAuthor ( String author ) { this . author = author ; } public String getId () { return id ; } public...

Automating DELETE request using Rest Assured

Image
In the previous post, we have learned about automating PATCH request using Rest Assured . In this Rest Assured tutorial, we will study about sending DELETE request using Rest Assured. I would highly recommend reading previous posts before proceeding with this one. A DELETE request will delete a resource on the server. Like PUT, this method is rarely permitted on the server for obvious reasons. The db.json file before sending the DELETE request is a follows: Now lets look at example of sending of DELETE request import org.testng.annotations.BeforeClass ; import org.testng.annotations.Test ; import static io. restassured . RestAssured .*; import io.restassured.RestAssured ; import io.restassured.http.ContentType ; public class DeleteRequestTest { @BeforeClass public void setBaseUri () { RestAssured. baseURI = "https://localhost:3000" ; } @Test public void deleteTest () { given() . when () . contentTyp...

To Check Response Time using Rest Assured

Image
In the previous post, we studied about automating delete request using Rest Assured. In this post, we will learn about checking the response time of REST API. I would highly recommend to read previous tutorials before reading this one. Response Time  is nothing but the total time taken to get REST API response. Let's look at the example to check the response time of API installed on our local system using Rest Assured. import org.testng.annotations.BeforeClass ; import org.testng.annotations.Test ; import io.restassured.RestAssured ; import static io. restassured . RestAssured .*; import static org. hamcrest . Matchers . lessThan ; public class VerifyResponseTime { @BeforeClass public void setBaseUri () { RestAssured. baseURI = "http://localhost:3000" ; } @Test public void responseTime () { given() . when () . get ( "/posts" ) . then () . time (lessThan ( 10 l)); } } In the setBaseUri ...

Popular posts from this blog

Using RequestSpecBuilder in Rest Assured ( Code Reuse )