Rest Assured Setup in Eclipse with Maven

In a real-time environment, we use Maven to manage the dependency of JAR files. Downloading JAR files and adding to the project structure is very cumbersome. So, we will learn how to set up rest assured in Eclipse with the help of pom.xml.

Follow the steps below to set up your own rest assured project structure in Eclipse.

How to start setting up a Rest Assured project in Eclipse?

First, create a maven project in Eclipse.

Creating new project in Maven

Add dependency of rest assured in pom.xml. For getting maven dependency, visit Maven Repository. 

Downloading Maven Dependencies

Copy the dependency and add it in pom.xml

Add Maven dependency of TestNG/Junit in your framework. These tests framework will help in managing tests. TestNG is preferable as compared to Junit because of additional features in TestNG. You can copy the dependency from Maven Repository and then paste it in pom.xml.

Post adding TestNG dependency, your pom.xml will look like:

Add Maven dependency of Jackson JSON java parser and JSON Schema Validator in pom.xml. JSON Schema Validator will be used to validate JSON Schema while JSON java parser will be used for parse JSON to map java objects to and from JSON. You can get these dependencies on the Maven repository.

After adding all the dependencies, the final pom.xml will look just like below.

<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
	<modelVersion&gt;4.0.0</modelVersion&gt;
	<groupId&gt;com.qatechhub</groupId&gt;
	<artifactId&gt;com.qatechhub.restassured</artifactId&gt;
	<version&gt;0.0.1-SNAPSHOT</version&gt;
	<packaging&gt;jar</packaging&gt;
	<name&gt;com.qatechhub.restassured</name&gt;
	<url&gt;http://maven.apache.org</url&gt;
	<properties&gt;
		<project.build.sourceEncoding&gt;UTF-8</project.build.sourceEncoding&gt;
	</properties&gt;
	<dependencies&gt;
		<!-- https://mvnrepository.com/artifact/org.testng/testng --&gt;
		<dependency&gt;
			<groupId&gt;org.testng</groupId&gt;
			<artifactId&gt;testng</artifactId&gt;
			<version&gt;7.1.0</version&gt;
			<scope&gt;test</scope&gt;
		</dependency&gt;
		<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured --&gt;
		<dependency&gt;
			<groupId&gt;io.rest-assured</groupId&gt;
			<artifactId&gt;rest-assured</artifactId&gt;
			<version&gt;4.3.1</version&gt;
			<scope&gt;test</scope&gt;
		</dependency&gt;
	<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core --&gt;
		<dependency&gt;
			<groupId&gt;com.fasterxml.jackson.core</groupId&gt;
			<artifactId&gt;jackson-core</artifactId&gt;
			<version&gt;2.11.1</version&gt;
		</dependency&gt;
	<!-- https://mvnrepository.com/artifact/io.rest-assured/json-schema-validator --&gt;
		<dependency&gt;
			<groupId&gt;io.rest-assured</groupId&gt;
			<artifactId&gt;json-schema-validator</artifactId&gt;
			<version&gt;4.3.1</version&gt;
		</dependency&gt;
	</dependencies&gt;
</project&gt;

After successful addition of dependencies, you will see JAR files in Maven dependencies in your project structure.

Conclusion

Hence, we are ready with the eclipse setup for rest assured. This is the time we should proceed to learn to implement tests in rest assured. Let us have a look at writing tests in BDD in the coming section.

Nancy Tuli

About the Author

Nancy Tuli