đź§© Scenario 1: Add a new pet to the store
Purpose:
Verify that a new pet can be successfully created in the store and that the response contains the expected data.
Steps:
- Send a
POST /petrequest with a valid pet object. - Verify that the response status code is
200. - Verify that the response body contains a valid pet
id. - Store this
idfor use in later requests.
Expected Result:
The new pet is created successfully, and a valid pet ID is returned in the response.
đź§© Scenario 2: Update an existing pet
Purpose:
Confirm that an existing pet’s details can be updated using the previously created pet ID.
Steps:
- Send a
PUT /petrequest using the savedpetId. - Modify one or more attributes (e.g.,
name,status). - Verify that the response status code is
200. - Verify that the updated values appear in the response.
Expected Result:
The pet’s details are successfully updated and reflected in the response.
đź§© Scenario 3: Find pet by ID
Purpose:
Ensure that the system can retrieve a specific pet using a valid pet ID.
Steps:
- Send a
GET /pet/{petId}request using the savedpetId. - Verify that the response status code is
200. - Verify that the returned
idmatches the expectedpetId.
Expected Result:
The correct pet details are returned for the given ID.
đź§© Scenario 4: Pet not found
Purpose:
Validate that the API correctly handles cases when a pet does not exist.
Steps:
- Send a
GET /pet/{invalidId}request with a non-existent pet ID (e.g.,999999). - Verify that the response status code is
404. - Verify that the response message indicates “Pet not found” or similar.
Expected Result:
The API returns a proper error response indicating the pet does not exist.
Fature scenarios
Feature: PetStore API Testing
This feature tests the PetStore API endpoints for creating, updating, retrieving, and handling non-existent pets.
Background:
Given the PetStore API is available
And I have the base URL "https://petstore.swagger.io/v2"
@create
Scenario: Add a new pet to the store
When I send a POST request to "/pet" with the following body:
"""
{
"id": 0,
"name": "fluffy",
"status": "available"
}
"""
Then the response status code should be 200
And the response should contain a valid "id"
And I store the "id" as "petId"
@update
Scenario: Update an existing pet
Given I have a stored "petId"
When I send a PUT request to "/pet" with the following body:
"""
{
"id": {{petId}},
"name": "fluffy-updated",
"status": "sold"
}
"""
Then the response status code should be 200
And the response body should contain "fluffy-updated" as the name
And the status should be "sold"
@get
Scenario: Find pet by ID
Given I have a stored "petId"
When I send a GET request to "/pet/{{petId}}"
Then the response status code should be 200
And the response body should contain "id" equal to {{petId}}
@notfound
Scenario: Pet not found
When I send a GET request to "/pet/999999"
Then the response status code should be 404
And the response body message should contain "Pet not found"

