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 API sandbox, RBP, to determine if it’s an application that they would like to use for a B&B. As they begin to explore RBP, 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 in Figure 4.1:
Figure 4.1: Example API documentation
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"]
}
However, rather than getting the expected room creation back in an HTTP response, they receive a 500 Server Error message. The error leaves them feeling a bit frustrated. They go back to the documentation to see what we might have missed but learn nothing new. In the end, they decide that this API isn't working correctly and move on resulting in lost business for us.