Sobes.tech
Senior

Which HTTP methods are covered by autotests? How does PATCH differ from PUT and POST?

sobes.tech AI

Answer from AI

Automated tests typically cover the main HTTP methods: GET, POST, PUT, PATCH, DELETE.

  • POST — used for creating new resources. POST requests are usually not idempotent; repeated calls may create duplicates.

  • PUT — used for completely updating a resource or creating it if it does not exist. PUT is idempotent: repeated requests with the same data will not change the result.

  • PATCH — used for partial updates of a resource. Unlike PUT, PATCH only changes specified fields. The idempotency of PATCH depends on the implementation, but it is generally considered that PATCH may not be idempotent.

Examples of differences:

  • POST /users — create a new user.
  • PUT /users/123 — completely replace the data of the user with id=123.
  • PATCH /users/123 — update, for example, only the email of the user with id=123.

In automated tests, the correctness of responses, status codes, server state changes, and idempotency for PUT and PATCH are checked if this is provided for by the API specification.