Users Online

· Guests Online: 105

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

Rest Assured Tutorial for REST API Automation Testing

Configure Eclipse with Rest-Assured

 

 

In the last tutorial, we went through the concepts of Rest-assured in theory. To start our practical journey, we need to write code that can send and receive the data with a lot more interesting twists in between. However, the medium that will help us in our API testing is an integrated development environment (IDE). In our case, we will be using the popular Eclipse IDE and in this post, we will prepare it for our coding exercises. In other words, we will configure eclipse with rest-assured for API testing. The index looks as follows:

  1. What are the prerequisites to configure Eclipse with Rest Assured?
  2. How to download rest-assured jars in Eclipse?
  3. Creating a project in Eclipse for rest assured.
  4. How to setup rest-assured jars in the class path?

What are the prerequisites to configure Eclipse with Rest Assured?

The first step towards setting up the development environment so that we can test some RESTful APIs is to evaluate the prerequisites. The following list highlights the required software for setting up Eclipse with rest-assured. Before proceeding, please make sure they are installed on your system.

  • Latest Java version.
  • Working Eclipse IDE.
  • TestNG setup.

If any of the above is not present on the system, then we have to follow the links given below :

  1. Set up Java
  2. Setting up Eclipse
  3. Set up TestNg

Once the prerequisites are up and running we can proceed with the rest assured set up on Eclipse.

How to download rest-assured jars in Eclipse?

The rest assured jar files can be downloaded from the following link.

https://github.com/rest-assured/rest-assured/wiki/Downloads.

When we navigate to this page, we can see the section “Current direct downloads”. Go to this section and click on the link to the dist package.

current_downloads

Note: At the time of this writing Version 4.4.0 is available for download.

Once the link is clicked, the browser will download the rest-assured-4.4.0-dist.zip file on the system (mostly in the "downloads" folder for Windows OS). Navigate to the folder where the zip file was downloaded and simply unzip the files.

Now go to the folder where the files were just unzipped and open it. The contents should be the following in this folder.

  • docs: A folder containing javadocs.
  • rest-assured-3.0.3.jar: jar file that contains rest-sssured classes.
  • rest-assured-3.0.3-deps.zip: Another zip file containing all the dependency jars.

Note: We have to also unzip the rest-assured-4.4.0-deps.zip dependency jars. In the end, your folder would look like this.

Rest Assured Library 3.3.0 deps folder content

Now that we have rest assured jars package ready,  we can go ahead and create a project in Eclipse that will use rest assured.

Creating a project in Eclipse for rest assured

To add and use unzipped rest assured jars in an actual project, we have to first create a new project in Eclipse. So we create a project, let's say, RestAssuredTest as shown below.

New Eclipse Java Project

Once clicked on the Java Project link, a new project window opens up. Enter the name of the project as RestAussuredTest and click on the Finish button. Once Finish is clicked, we get the following screen. Click Open Perspective. (Alternatively, if we have already checked the option "remember my decision", then this step will not be seen)

Java Project Creation

Now the project with the name RestAssuredTest should display in the package explorer.

Eclipse Project

Once the project is created in Eclipse, now it is required to add the unzipped jars in the classpath of the Eclipse project.

How to setup rest-assured jars in the class path?

Select the Java project folder we just created and right-click on the project folder in the package explorer pane and choose Properties. This will open up the project properties pop-up window as shown below.

Project Properties

Select  Java build path option in the left pane of the properties window. In the Java build path pane, on the left-hand side, you will see the Libraries pane.

Set Rest Assured Library path

Here we are going to reference the rest assured jar files that we downloaded earlier. To reference the jars,  click on the "Add external jars" button and navigate to the folder where we unzipped all our rest-assured jars. Refer to the image shown below.

Add Rest Assured Jars to Eclipse Project

Now include the following Jars

  • rest-assured-3.3.0.jar
  • All the jars in the folder rest-assured-3.3.0-deps

With this, we have successfully set up a Java project in Eclipse with a rest-assured library. If we now check the project explorer, we will get the following view.

Eclipse ProjectExplorer

Now we are ready to use Rest Assured features in Eclipse.

Key TakeAways

In this article, we configured the Eclipse project with Rest Assured Library.

  • Rest Assured library comes in the form of jars which we can download freely from GitHub and unzip on our local machine.
  • The prerequisites for using Rest Assured jars are we should have Java, Eclipse, and TestNG properly configured and running on the machine.
  • We can then create a Java project in Eclipse and associate the Rest Assured jars with it by specifying the jar path in the Build path.

With these steps, we can configure Rest Assured with the Eclipse project. In the next article, we will create a simple REST API with the Rest Assured library.

 

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 0.95 seconds
10,852,568 unique visits