This project automates testing of the Swagger PetStore API using Rest Assured. It includes automated test cases for Pet, User, and Store APIs, providing comprehensive coverage for common operations. The project uses Maven for build management and integrates Allure for detailed test reporting.
- Project Overview
- Pre-requisites
- Technologies Used
- Project Structure
- Test Scenarios
- Setup and Execution
- Generating Allure Reports
This project automates RESTful API testing for the PetStore application, focusing on:
- Pets
- Users
- Store Orders
It performs functional testing, API response validation, and status code verification using the Rest Assured library. The test suite is integrated with Allure to generate detailed test reports for better insights into test execution.
Ensure the following are installed on your system:
- Java JDK (8 or higher)
- Maven (3.x)
- Allure Commandline (for generating reports)
- An IDE (e.g., IntelliJ IDEA or Eclipse)
- Rest Assured: API testing framework
- Maven: Build and dependency management
- JUnit/TestNG: Test management frameworks
- Allure: Test reporting tool
- Jackson: JSON parsing library
- Swagger PetStore API: The target API
├── src
│ ├── main
│ │ └── java
│ └── test
│ └── java
│ ├── api.tests # Contains the API test classes
├── allure-results # Allure results for reporting
├── pom.xml # Maven dependencies and configurations
└── README.md # Project documentation
The following scenarios are automated in this project:
- Add a new pet (
POST /pet
) - Update an existing pet (
PUT /pet
) - Find a pet by ID (
GET /pet/{petId}
) - Delete a pet by ID (
DELETE /pet/{petId}
)
- Create a user (
POST /user
) - Get user by username (
GET /user/{username}
) - Update user details (
PUT /user/{username}
) - Delete a user (
DELETE /user/{username}
)
- Place an order for a pet (
POST /store/order
) - Get order by ID (
GET /store/order/{orderId}
) - Delete order by ID (
DELETE /store/order/{orderId}
) - Get inventory (
GET /store/inventory
)
- Response validation (status codes, headers, body)
- Edge cases for invalid data
git clone https://github.com/SanjanaVarma12/petstore-api-automation-rest-assured.git
Import the project into your IDE (e.g., IntelliJ IDEA or Eclipse) as a Maven project.
Navigate to the project directory and execute the following command:
mvn clean test
This command will compile the tests and execute the automated test suite.
To generate and view Allure reports, you need to have Allure installed.
For Mac users, you can install Allure via Homebrew:
brew install allure
For Windows/Linux users, follow the installation instructions provided in the Allure documentation.
After running the test suite, generate and serve the Allure report with the following command:
allure serve target/allure-results
This will automatically open the Allure report in your default browser. The report includes:
- Overview: Summary of test results (passed, failed, skipped tests)
- Suites: A breakdown of individual test cases
- Graphs: Visual representation of test performance
- Timeline: Time distribution for test execution
To generate a static HTML report without starting a web server, run:
allure generate target/allure-results --clean
The static report will be saved in the allure-report
directory, and you can open the index.html
file to view it locally.