Test if an API Service is available



  • I'm creating a test suite for a test that should check that a specific API Service is available. So I'm confused on exactly how I can check the availability of a service. Is it sufficient to only check the status code to be 200 or are there other ways to confirm that?



  • It depends on how you define "available". Making a simple call and checking that you get a code 200 means the servers is up and it can recieve calls.

    Now if the API uses for example a database then the simple call might not detect underlying systems are wrongly configured.

    Personally I would want to ensure the API and its depencies are working. So doing a call that actually does something and verifying the result would make more sense. But you might not want to call API's that insert/change data.

    I would suggest to ask the developers to add a HealthCheck method, that checks the internals of the API and gives a small json report to check.



Suggested Topics

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