Web Services Testing


Creation of a Test Case for Web Service/API Testing is no different than the creation of a Test Case for a Web/Mobile Application.

Please refer this article for a detailed guide on Creating / Editing/ Deleting Test Cases - How to add/edit/delete automated Test Case?


The Test Step creation is similar for all types of applications ( Web and Mobile ) except Web Services.

You can navigate to the Test Cases page by going through:


Applications > Create/Select Application > Create/Select Version > Create/Select Test Case


Selecting the Test Case takes us to the Test Case details page. we will be creating the RESTful Test Steps here. Click on the Create Test Step button to continue. The Create Test Step page will be opened as shown below:



Web Service Test Step creation


Select from one of the Test Steps specification type:

  • Template
  • Step Group
  • Custom Function


We will be focusing on creating a RESTful Test Step using Template in this case. Step Group creation and Custom Function creation for Web Services are no different when compared to the same for other Application types. You can check the below articles for more details.


How to create a Step Group in Automated Test Case?

How to use Custom Functions in Testsigma?


Enter the input data as follows:


Title: Enter a title for the Test Step.


URL: The web address endpoint of the RESTful Web Service to perform testing on.


Http Methods: Select from one of the HTTP request types to perform:

  • GET, POST, PUT, DELETE, or HEAD

Please refer to this article for more details on creating Tests for various HTTP request types - Usage of various HTTP requests for REST API Testing in Testsigma


Header: Select the JSON data format in which Request Header is to be provided

  • JSON String - Enter the Request as a JSON String
  • JSON Key-Value pair - Enter the Request as a pair of JSON key and value
    • Add Row: Add additional request data rows to enter more data.


Payload: Enter the Request Body to be sent for POST, PUT, and DELETE request types.


Test: Select one of the test types to perform:

  • Status Code, Header Test, Body Test or All


Expected Status Code: Enter the status code expected in response.


Header/Body Compare Type: Select any one of the following options to specify the header/body comparison method(comparison rigidity):

  • Strict - Not extensible, and strict array ordering.
  • Lenient - Extensible, and non-strict array ordering.
  • Non-extensible - Not extensible, and non-strict array ordering.
  • Strict order - Extensible, and strict array ordering.

Please check this article for more details on Comparison Modes - Comparison Modes in Web Services Testing


Header Test: Enter the expected Response Header content.


Body Content-Type: Select any one of the following options to specify the Response Body content type:

  • Strict, Lenient, Non-extensible, Strict order, JSON Schema, or JSON path


Body Test: Enter the expected Response Body content.


Store Metadata: Check this option to store the Response as metadata for debugging purposes.


Header Runtime Data: Enter the variable and JSON Path in the following format to save the Header Data in runtime.

<variable_name>:<JSON_Path>


Body Runtime Data: Enter the variable and JSON Path in the following format to save the Body Data in runtime.

<variable_name>:<JSON_Path>


After entering all the required details, click on Create button to create the Test Step.


Examples


In an example, let us see how the following steps are created using Testsigma:

1. Verify the response status code(200) for an HTTP request sent to http://restapi.demoqa.com/utilities/weather/city/Hyderabad
2. Verify the Response Body for a GET HTTP request sent to http://restapi.demoqa.com/utilities/weather/city/Hyderabad using lenient comparison
3. Verify the Response Header for a GET HTTP request sent to http://restapi.demoqa.com/utilities/weather/city/Hyderabad using lenient comparison


The REST call Endpoint is http://restapi.demoqa.com/utilities/weather/city/Hyderabad
Expected Status code for a successful request is 200
A portion of Expected Body is {“City”: “Hyderabad”}
A portion of Expected Header is {"Connection" : "keep-alive"}
Comparison type is lenient




Welcome to the era of #SmartTestAutomation with #Testsigma!