What do you assert on when doing API testing?

  • Status codes and response times are great things to assert on every request.
  • Check the response is coming back how you expect. you can assert the format (is it a string, object, array, null?)
  • if you’ve changed data with your POST or PUT/PATCH is that coming back in the response?
  • Checking validation. Does the response have error text you can validate and make assertions against?
  • Assert any headers that are being returned and they are in the correct format?
  • Assert a token is being returned?
  • If you supply an invalid verb for that request you can assert to response.
4 Likes