Sunday, August 22, 2021

Post#140-API#9 Parsing Json String using GSON library

 ðŸ‘‡

To use GSON library you have to add maven dependency in your project.

GSON as a Maven dependency looks like this:

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.8</version>
</dependency>

 Let's take the below JSON as an example:

Post#139-API#8 Rest Assured GET Test

 ðŸ‘‡

Before we create our REST Assured tests, make sure that you have added Rest Assured library and TestNG library in your Maven project.

In this tutorial I am using below URL for different request.

https://reqres.in/

Below code snippet shows how to call GET method and test response JSON elements.

package testcase2;

import org.testng.annotations.Test;

import io.restassured.RestAssured;

Post#138-API#7 The components of a URL

 ðŸ‘‡

A URL (Uniform Resource Locator) is a specific type of URI (Universal Resource Identifier). A URL normally locates an existing resource on the Internet. A URL is used when a web client makes a request to a server for a resource.

Briefly, a URI is defined as any character string that identifies a resource. A URL is defined as those URIs that identify a resource by its location or by the means used to access it, rather than by a name or other attribute of the resource.

Saturday, August 21, 2021

Post#137-API#6 Idempotency with HTTP Methods

 ðŸ‘‡

What Is Idempotent in REST?

In the context of REST APIs, when making multiple identical requests has the same effect as making a single request – then that REST API is called idempotent.

An idempotent HTTP method is an HTTP method that can be called many times without different outcomes. It would not matter if the method is called only once, or ten times over. The result should be the same.

Idempotency with HTTP Methods

If you follow REST principles in designing API, you will have automatically idempotent REST APIs for GET, PUT, DELETE, HEAD, OPTIONS and TRACE HTTP methods. Only POST APIs will not be idempotent.

Post#136-API#5 HTTP Methods

 ðŸ‘‡

Before we start scripting with Rest Assured Lets understand what are these methods GET, POST, PUT, PATCH , DELETE etc.

GET

GET requests are the most common and widely used methods in APIs and websites. Simply put, the GET method is used to retrieve data from a server at the specified resource. For example, say you have an API with a /users endpoint. Making a GET request to that endpoint should return a list of all available users.

Idempotent REST APIs

In the context of REST APIs, when making multiple identical requests has the same effect as making a single request – then that REST API is called idempotent.

An idempotent HTTP method is an HTTP method that can be called many times without different outcomes. It would not matter if the method is called only once, or ten times over. The result should be the same.

Post#135-API#4 Rest assured Introduction and set up

👇 

What is Rest assured?

Rest assured is java library for testing Restful Web services. It can be used to test XML & JSON based web services. It supports GET, POST, PUT, PATCH, DELETE, OPTIONS and HEAD requests and can be used to validate and verify the response of these requests. Also it can be integrated with testing frameworks like JUnit, TestNG etc.

Prerequisites: Java, IDE (Eclipse, IntelliJ, etc), Maven & TestNG

The benefits of REST Assured

There are three main aspects of REST Assured that make it a powerful library for API testing:

Post#134-API#3 API v/s Web Service

 API v/s Web Service

Web services facilitate communication between two web parties in compliance with communication standards and protocols like Extensible Markup Language (XML), Simple Object Access protocol (SOAP), Web Services Description Language (WSDL) and Universal Description, Discovery and Integration) UDDI and all of these collectively known as Web Services. API and Web service serve as a means of communication. The only difference is that a Web service facilitates interaction between two machines over a network. An API acts as an interface between two different applications so that they can communicate with each other. An API is a method by which the third-party vendors can write programs that interface easily with other programs. A Web service is designed to have an interface that is depicted in a machine- executable format usually specified in Web Service Description Language (WSDL- generally is an API). Typically, “HTTP” is the most commonly used protocol for communication. Web service also uses SOAP, REST, and XML-RPC as a means of communication. API may use any means of communication to initiate interaction between applications. For example, the system calls are invoked using interrupts by the Linux kernel API.

Post#133-API#2 API Testing Types

 ðŸ‘‡

Validation Testing

Validation testing occurs among the final steps and plays an essential role in the development process. It verifies the aspects of product, behavior, and efficiency. In other words, validation testing can be seen as an assurance of the correct development.

Functional testing

Includes testing particular functions in the codebase. These features are the representation of specific scenarios to make sure the API functions are handled well within the planned parameters.

Friday, August 20, 2021

Post#132-API#1 Introduction to API Testing

 

👇

Application Program Interface (API): Is the way of communication between two applications where applications may differ in their platforms or in terms of technology also.

Diagrammatically Representing And Understanding What Exactly API’s Are: