Installation of Rest Assured

You may face the below error if you are using the older version of the eclipse; please update the eclipse versions. I am currently using Version: 2020-06 (4.16.0) Build id: 20200615-1200

java.lang.SecurityException: class "org.hamcrest.Matchers"'s signer information does not match signer information of other classes in the same package

Installation of rest assured requires 4 software.

  • Java
  • Eclipse
  • Maven

In the Maven, we will be using multiple dependencies, so rest assured will be one of the dependencies in the Maven.

For the first lesson, we will be getting started with rest assured dependency along with JUnit dependency.

Open eclipse and go to File> New > Project;


Scroll down, you can see my one show in the Maven select Maven project.


Once you select a Maven project, then Select Create a simple project.


You have to provide artifact id and group ID; the group ID and artifact ID will be used as part of a pom.xml, and artifact ID is going to be your project name.


Then click on the Finish button.


Now we have created the Maven project, but we have to add the dependencies to use our rest assured. Our rest assured jars are present as part of the Maven repository so we can use those rest assured jars from the Maven repository.

To add the dependencies, open the pom.xml file present in the project. Select the pom.xml tab to view the XML content



You can visit the Maven repository(, or you can search rest assured Maven in Google to get the link or to get the web page from where you can copy the dependencies.


Choose the version that you want to use in your project; for this tutorial purpose, I am going to use the latest version, and the versions may change when you are reading this particular tutorial, so use a version according to your project.


Select the Maven tab, and you can copy the content present inside the textbox and paste the copied content into your pom.xml file.

Similarly, search for Junit jars in the Maven repository and add them into your pom.xml. You have to place these dependencies inside the <dependencies> tag

	  <!-- -->
	  <!-- -->

Save the pom.xml file now it will download all the jars from the Maven repository.

With this, we are ending the installation of rest assured the below topic would cover how to get started with rest assured.

First RestAssured test

We can write test cases in different formats using rest assured. In the below example, I am not explaining much of the things, but this example is to check whether your setup is working or not.

We have a dedicated chapter on different formats of using rest assured.

As of now, I am going to retrieve all the products present in an API endpoint This endpoint is present on our website itself, and you can access the UI of the endpoint at

Setting the Latest JRE:

Create a new package called com.products under src/test/java

Create a new Class under the above-created package


After creating a class, you might see the below error.

The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor


Click on the configure build path.


Select the JRE System Library and click Remove button


Select the workspace default JRE




After adding all the libraries, the errors are gone, lets see how to write the first test case.

First Rest assured code:

We will be writing out the first code with rest assured to print the response from the server.

  • RestAssured: Most of the request related methods are present in RestAssured class as static methods.
  • given() : preparing the request
  • when() : preparing the request
  • get() : creates the request and send to the server
  • prettyPrint() : prints the response to the console.

Paste the following code into the editor.

package com.products;
import io.restassured.RestAssured;
public class FirstRestAssuredTest {
	public static void main(String[] args) {



First Rest assured Test:

In the above test, We have seen how to create a request and send it to the server, and we were able to print the response that we received from the server.

In the below program, we are going to test the above code, whether we are receiving the 200 status code or not.

import org.junit.jupiter.api.Test;
import io.restassured.RestAssured;
public class FirstRestAssuredTest {
	void sampleTest() {

So whenever we say test, we need to have some testing Framework, so for this purpose, we have already introduced the dependency of JUnit, so we are going to use it as unit test Framework here.

Set the new Launcher for the project; set the JUnit5 as the launcher.


Output is


Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions