Testing with SRTs
Design and Build Great Web APIs — by Mike Amundsen (70 / 127)
👈 The Goals of API Testing | TOC | Using Postman for API Testing 👉
An easy way to start testing your API is to focus just on the interface itself with what I call simple request tests, or SRTs. SRTs are just what the name sounds like: a simple HTTP request you can run to validate that the minimal elements of the API are working as you would expect. And that’s how I use SRTs — to validate the API.
Here are a few examples of SRTs used for testing an API that supports managing people’s contact information:
# person api test requests
# 2020-02 mamund
http://localhost:8181/
http://localhost:8181/list/
http://localhost:8181/filter?status=active
http://localhost:8181/ -X POST -d \
id=q1w2e3r4&status=pending&email=test@example.org http://localhost:8181/q1w2e3r4 -X PUT -d \
givenName=Mike&familyName=Mork&telephone=123-456-7890
http://localhost:8181/status/q1w2e3r4 -X PATCH -d status=active
http://localhost:8181/q1w2e3r4 -X DELETE
# EOF
I also used some SRTs very early in the book in Exploring APIs with curl.
Because HTTP APIs rely on URLs, HTTP methods, and a few HTTP headers, tools like curl give you all the power you need to create a collection of SRTs that you can run against your API. You can do this while you’re implementing the API as a…