Skip to content

2. Test Data set up using Virtualan

Elan Thangamani edited this page Aug 30, 2020 · 1 revision

Virtualan has RESTAPI and user-friendly interface (UI) to set up the test data for your specific type of Rest APIs. This UI would help Developer, Functional Tester or Automation Tester to set up the test data for their specific use cases and test scenarios.

Virtualan would perform a "Request Matching" with following attribute choices:

  • End point Rest URL
  • HTTP Verbs
  • Query/Path/Header parameters
  • Request message body

To Access Virtualan UI

  1. Navigate to Virtualan UI with following URL: http://localhost/virtualan-ui.html#/ Virtualan Home Page
  2. From “Virtual Service” menu: select “Add Mock” drop-down:
  3. Select appropriate API operation that would need to set up
  4. This User interface would be grouped by API’s parent resource:
  5. For this case, it would be “pets” with different APIs

Set up data for POST API:

a) Set up the data for /pets – POST API b) Populate the Request data with “Mock Request Body:” test area and Response would be in the “Mock Response:”. c) Provided the above data, click on “Add” so that the mock response will be added.

d) A success message will be seen after you click on “Add”. e) If you add the same “Request Test Data” again it would fail with the “Data already exists”. f) Validation of the “Post” /pets API in postman(any Rest client):

  1. Open the Postman application and select http method as “Post”
  2. Enter the URL http://localhost/api/pets
  3. Enter the same Request information would be used to create the “Test Data”
  4. Response for the above “Post” API /pets request.

Set up data for GET API:

a) Set up the data for /pets/{id} – GET API b) Populate the Request data in PathParam and Respose would be in the “Mock Respose:” c) Provided the above data, click on “Add” so that the mock response will be added.

d) A success message will be seen after you click on “Add”. e) Validation of the “GET” /pets/7001 API in postman(any Rest client):

  1. Open the Postman application and select http method as “Get”
  2. Enter the URL http://localhost/api/pets/7001
  3. Response for the above “Get” API /pets request.

Set up data for PUT API:

a) Set up the data for /pets/{petId} – PUT API b) Populate the Request data with “Path Param” and “Mock Request Body:” and Expected respose would be in the “Mock Respose:”. c) Provided the above data, click on “Add” so that the mock response will be added.

d) A success message will be seen after you click on “Add”. e) Validation of the “PUT” /pets/7001 API in postman(any Rest client):

  1. Open the Postman application and select http method as “Put”
  2. Enter the URL http://localhost/api/pets/7001
  3. Response for the above “Put” API /pets request.

Set up data for DELETE API:

a) Set up the data for /pets/{id} – Delete API b) Populate the Request data in PathParam and expected response in the “Mock Response:” c) Provided the above data, click on “Add” so that the mock response will be added.

d) A success message will be seen after you click on “Add”. e) Validation of the “DELETE” /pets/7001 API in postman(any Rest client):

  1. Open the Postman application and select http method as “Delete”
  2. Enter the URL http://localhost/api/pets/7001
  3. Response for the above “Delete” API /pets request.