Skip to content

Instantly share code, notes, and snippets.

@sgrebnov
Created October 20, 2023 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgrebnov/3fd021c3b43fef4f72a0d2ee0c5ddb23 to your computer and use it in GitHub Desktop.
Save sgrebnov/3fd021c3b43fef4f72a0d2ee0c5ddb23 to your computer and use it in GitHub Desktop.

Here is a list of diverse test scenarios for the POST /pet API (Add a new pet to the store):

  1. Positive Test Case - Valid Request:

    • Send a valid POST request with all required parameters (name, category, photoUrls) and optional parameters (tags, status) set appropriately.
    • Verify that the response status code is 200 (Successful operation).
    • Check that the response body contains the newly added pet's details.
  2. Negative Test Case - Missing Required Parameters:

    • Send a POST request with missing one or more required parameters (e.g., name or photoUrls).
    • Verify that the response status code is 405 (Invalid input).
    • Check that the response body contains an error message indicating missing parameters.
  3. Negative Test Case - Invalid Status Value:

    • Send a POST request with an invalid status value (e.g., "invalid_status").
    • Verify that the response status code is 405 (Invalid input).
    • Check that the response body contains an error message indicating the invalid status value.
  4. Edge Case - Maximum Length for Name and Photo URLs:

    • Send a POST request with the name and photoUrls fields containing values at their maximum allowed length.
    • Verify that the response status code is 200 (Successful operation).
  5. Edge Case - Empty Tags Array:

    • Send a POST request with an empty array for tags.
    • Verify that the response status code is 200 (Successful operation).
  6. Edge Case - Special Characters in Name:

    • Send a POST request with a pet name containing special characters (e.g., "Fluffy&Fido").
    • Verify that the response status code is 200 (Successful operation).
  7. Edge Case - Multiple Photo URLs:

    • Send a POST request with multiple photo URLs in the photoUrls array.
    • Verify that the response status code is 200 (Successful operation).
  8. Edge Case - Maximum Length for Tags:

    • Send a POST request with a tags array containing the maximum number of tags.
    • Verify that the response status code is 200 (Successful operation).
  9. Positive Test Case - Duplicate Pet Addition:

    • Add a pet with a unique name.
    • Send another POST request with the same pet name.
    • Verify that the response status code is 200 (Successful operation) and that a new pet is added with a different ID.
  10. Negative Test Case - Unauthorized Access:

    • Send a POST request without proper authentication or API key.
    • Verify that the response status code is 401 (Unauthorized).
  11. Negative Test Case - Malformed JSON Request Body:

    • Send a POST request with a request body that is not valid JSON.
    • Verify that the response status code is 400 (Bad Request).
  12. Edge Case - Large Request Body:

    • Send a POST request with a very large request body, exceeding the server's limits.
    • Verify that the response status code is 413 (Request Entity Too Large).
  13. Negative Test Case - Unsupported Media Type:

    • Send a POST request with a request body in an unsupported media type.
    • Verify that the response status code is 415 (Unsupported Media Type).
  14. Negative Test Case - Server Error:

    • Simulate a server error by sending a POST request with a known condition that triggers a server error.
    • Verify that the response status code is 500 (Internal Server Error).
  15. Edge Case - Concurrency Test:

    • Simulate multiple concurrent POST requests to add pets simultaneously.
    • Verify that all requests are handled correctly, and no data is corrupted.
  16. Edge Case - Maximum Tags and Maximum Photo URLs:

    • Send a POST request with the maximum number of tags and photo URLs allowed.
    • Verify that the response status code is 200 (Successful operation).

These test scenarios cover a range of positive, negative, and edge cases for the POST /pet API, ensuring comprehensive testing of its functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment