30 Days of API Testing (ministryoftesting)

30 Days of API Testing (ministryoftesting)

Tags
API Testing
Published
February 29, 2024
Author

Exercise 1:

Using https://automationintesting.online created by Mark Winteringham and myself, do the following:
  • Assert on the correct status code and that the body has a room object.
{ "username": "admin", "password": "password" }

Share

Post your experiences with the tools you use below.
If you used a different API post the calls you did so others can try them.
 

Kết quả

notion image
 
notion image
notion image

Exercise 2:

 
Using https://automationintesting.online created by Mark Winteringham and myself, do the following:
{ "username": "admin", "password": "password" }
  • Extract the token and store it
  • Do a POST call against the booking API to make a booking for the room, https://automationintesting.online/booking/. The JSON should look like this, changing the data as you like and ensuring you map to the roomid you stored earlier.
  • You’ll also need to send your token as a cookie.
{ "bookingdates": { "checkin": "2018-11-01T09:48:25.469Z", "checkout": "2018-11-01T09:48:25.469Z" }, "depositpaid":true, "firstname": "string", "lastname": "string", "roomid": <<roomid>>, "totalprice": 0 }

Share

Post your experiences with the tools you use below.
If you used a different API post the calls you did so others can try them.
 
Yep one {...} is used to define a single object, while the other [...] is used to define a sequence of either objects, values or lists ...
objects are defined as such {key:object or list or value , ...} list ares nothing more than a sequence of either objects or lists or values, [objects or list or values, ... ]...
[{'value':1}, {'values':[1,2,3,3, {'a':'a', 'b':'b'}]}, 2, 3, 4]

Kết quả

notion image
notion image
notion image
notion image
notion image

Objectives

  1. Loop through a dataset calling an API each time
  1. Gain exposure to many some API testing automation frameworks or tools that support API automation.
 

Example

Using https://automationintesting.online created by Mark Winteringham and myself, do the following:
{ "username": "admin", "password": "password" }
  • Extract the token and store it
  • Create test data like below, perhaps parameterise the name and date fields
{ "bookingdates": { "checkin": "2018-11-01T09:48:25.469Z", "checkout": "2018-11-01T09:48:25.469Z" }, "depositpaid":true, "firstname": "<<paramterised data>>", "lastname": "string", "roomid": "<<roomid>>", "totalprice": 0 }

  1. Get a token then save to request headers
  1. Add more rooms for booking management system
  1. Get a list of room ids
  1. Make a booking for each room then verify info
 
  • Create the bookingdata.csv file for the data
    • notion image
  • Update the body of request to booking to using the data from file instead using the hard-code data.
    • notion image
  • Running the collection with the data file:
    • notion image
      Note: To make sure the data is correct, using the Preview button
      notion image