Introduction to RESTful api testing using soapUI

REST: Introduction.

The term REST is an abbreviation to Representational State Transfer. It is one of several architecture styles in which software systems are designed. It is not a W3 standard as SOAP and is easier to use. All REST communications are stateless and use common HTTP methods. Everything is represented by a unique ID or a uniform resource identifier. Further discussion on REST is beyond the scope of this article.

Testing RESTful APIs with soapUI:

Now when we have the basic understanding of REST, it’s time to get started with testing some REST APIs. We have a lot of freely available REST APIs to play around. Lets use google APIs as they are RESTful and free to use. We will be using google directions api for the sake of understanding and simplicity. Lets get started.

Click on ‘File’ on the top left corner and then select ‘New REST project’

rest-1

Now the New REST Project window appears and asks for a URI as shown in the image below.

rest-2

You need to enter the base URI of your project here and in our case it is https://maps.googleapis.com/maps/api/directions/{format}, so paste this in URI field and click on OK.

Now you should see a request editor something like the image below.

rest-3

In the above image, we see a methods dropdown where we have selected GET. This dropdown has all standard HTTP methods as discussed previously. We have selected GET as we only want to retrieve data. The endpoint is the base URI we provided while creating the project. Now we come to the important part which are the parameters. We can get all the parameters from the api documentation. For now we will be using few basic parameters like origin and destination. We also see that there is a parameter called format already present, we need to change its value to json/xml. In order to add a new parameter click on the button shown in the above image. Add relevant values to your parameters and save. Now the request editor appears like the image below.

rest-4

Now run the request and we get the directions from origin to destination as response.

We can now add assertions and design test cases in a similar way as we did for SOAP so as to meet our requirements.

More coming soon!!

Leave a comment