Posts

Showing posts with the label Automate Rest Services Testing

Automate Testing of Rest Services using Rest Assured

Image
Rest Assured is a java library for testing of REST services. An official guide of Rest Assured can be found here:  Rest Assured Official Guide Introduction: REST Services are used for communication between two platforms which may be are developed using different languages or technologies. The reason behind automation rest services is that it takes less time as well as it helps to find defects earlier as it can be tested before UI is developed. What are Rest API's: REST  is the underlying architectural principle of the web. The amazing thing about the web is the fact that clients (browsers) and servers can interact in complex ways without the client knowing anything beforehand about the server and the resources it hosts. The key constraint is that the server and client must both agree on the  media  used, which in the case of the web is  HTML . Rest API's are stateless and cacheless. They don't store information. REST is implemented in XML as w...

Testing GET Requests and their Responses using Rest Assured

Image
What is a GET Request? The GET method is used to retrieve information from the given server using a given URI. Requests using GET should only retrieve data and should have no other effect on the data. Way to send GET Request using Rest Assured and Check Status Code: For this exercise, we will use Google Places API ( Place Search ). You can view the API at below link : Google Place Search API We will learn about the Text Search GET request of Google Places API. A Text Search request is an HTTP URL of the following form: https://maps.googleapis.com/maps/api/place/textsearch/output?parameters where  output  may be either of the following values: json  (recommended) indicates output in JavaScript Object Notation (JSON) xml indicates output as XML Certain parameters are required to initiate a search request. As is standard in URLs, all parameters are separated using the ampersand ( & ) character. Testing HTTP Error Codes We will verify t...

Extracting a JSON Response with Rest-Assured

Image
In the earlier post, we studied about Testing GET Requests and their Responses using Rest Assured , before following this tutorial, I would recommend reading the previous one. In this post, we will learn about extracting JSON Response using Rest Assured. Once the response is extracted we will store it into Response class and later various tests can be performed to check whether extracted response is correct. I would assume that everyone following this tutorial has knowledge of Java and TestNG. If you need help then please follow tutorials on Java and TestNG . Now let's look at an example where we will search for a particular Railway Station in Mumbai City and print the response. import org.testng.annotations.BeforeClass ; import org.testng.annotations.Test ; import io.restassured.RestAssured ; import io.restassured.http.ContentType ; import io.restassured.response.Response ; import static io. restassured . RestAssured .*; public class GetJsonResponseTest { ...

Popular posts from this blog

Extracting an XML Response with Rest-Assured