4 Testing API designs

 

This chapter covers

  • Using question techniques to test designs and ideas
  • How to get teams collaborating around API designs to help facilitate testing
  • Documenting APIs to increase shared understanding and assist in testing
  • How testing API designs sits in a testing strategy

Imagine that someone is assessing our restful-booker-platform API sandbox to determine whether it’s an application that they would like to use for a B&B. As they begin to explore it, they discover that the room API needs to be called to create a room that can be booked. As they look through the API documentation, they come across details similar to the ones shown in figure 4.1.

Figure 4.1 An example of API documentation that might be found on a vendor’s website
CH04_F01_Winteringham

Based on this information, we build and send the following HTTP request to see how the API responds:

POST /room/ HTTP/1.1
Host: automationintesting.online
Accept: application/json
Cookie: token=r76BXGVy8rlASuZB

{
       "roomNumber":100,
       "type":"Single",
       "accessible":false,
       "description":"Please enter a description for this room",
       "image":"https://www.mwtestconsultancy.co.uk/img/room1.jpg",
       "roomPrice":"100",
       "features":["WiFi"]
}

4.1 How do we test API designs?

4.1.1 Tools for questioning

4.1.2 Expanding your API design-testing techniques and tools

4.2 Using API documentation tools to test designs

4.2.1 Documenting APIs with Swagger/OpenAPI 3

4.2.2 Beyond documentation

4.3 Encouraging teams to test API designs

4.3.1 Getting buy-in and initiating opportunities to test API designs

4.3.2 Taking advantage of existing sessions

4.3.3 Establishing your own sessions

4.4 Testing API designs as part of a testing strategy