Advice on assertions to make when creating an API testing framework



  • I'm currently looking at building an API test automation framework for a series of Rest Services, utilising c#. Coming from a UI-automation background I was after some advise on assertions when testing against an API.

    Obviously there are a whole array of different assertions that can be carried out but based on peoples experiences are there certain assertions that must be done? e.g. that the Expected Status Code is returned? Or is this something that can only be ascertained once the API definitions are in place?



  • That depends on what exactly you're going to test. If you're going to test only API logic, then you should assert

    • Response codes
    • Response body (since API methods often return objects within the body)
    • Less likely but: assert the API response time

    If you want to verify how HTTP server (that manages the requests and responses) works in combination with your API you would probably need to implement assertions of HTTP headers. It also worth implementing assertion of a raw response so that the user of your framework will be able to assert raw response with regular expressions for example.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2