API test automation project for the public Swagger Petstore API, built with Java, Rest Assured, JUnit 5, Maven and Jackson.
The project demonstrates automated API testing for user, store and pet endpoints, including functional, negative and cleanup scenarios.
- Java 17
- Maven
- Rest Assured
- JUnit 5
- Jackson Databind
- Maven Surefire Plugin
The test suite covers common backend API testing scenarios:
- Sending
GET,POST,PUTandDELETErequests - Validating HTTP status codes
- Validating JSON response bodies
- Working with path parameters
- Working with query parameters
- Creating test data dynamically
- Cleaning up created test data where possible
- Testing negative cases and invalid input
Covered scenarios:
- Create a user
- Get user by username
- Update an existing user
- Try to get an unknown user
- Try to log in without a required password query parameter
Covered scenarios:
- Place an order
- Get order by ID
- Delete order
- Get store inventory
- Try to get an order with an invalid ID
Covered scenarios:
- Add a pet
- Get pet by ID
- Delete pet
- Find pets by status
- Try to get a pet using a non-numeric ID
src/test/java/com/petstore
├── base
│ └── BaseApiTest.java
├── model
├── tests
│ ├── PetApiTests.java
│ ├── StoreApiTests.java
│ └── UserApiTests.java
└── util
Main parts:
base— shared Rest Assured setupmodel— request/response modelstests— API test classesutil— test data helpers
The tests use the public Swagger Petstore demo API:
https://petstore.swagger.io/v2
Request specification is configured in BaseApiTest with:
- base URI
- base path
- JSON content type
- request/response logging when validation fails
Clone the repository:
git clone https://github.com/Awvyyy/petstore-api-tests-java.git
cd petstore-api-tests-javaRun all tests:
mvn testRun a specific test class:
mvn test -Dtest=UserApiTestsmvn test -Dtest=StoreApiTestsmvn test -Dtest=PetApiTestsSwagger Petstore is a public shared demo environment. Because of that:
- Some data may already exist
- Other users may change data at the same time
- Exact data assertions can sometimes be unstable
- Dynamically generated test data is used to reduce collisions
- Cleanup is included after create operations where possible
- Generate a unique user
- Send
POST /user - Send
GET /user/{username} - Verify username, first name and email
- Delete the created user
- Generate an order
- Send
POST /store/order - Send
GET /store/order/{orderId} - Send
DELETE /store/order/{orderId} - Verify the order is no longer available
- Generate a pet
- Send
POST /pet - Send
GET /pet/{petId} - Verify pet ID, name and status
- Delete the created pet
A short testing report is available in REPORT.md. It describes:
- Framework choice
- Tested endpoints
- Functional scenarios
- Negative scenarios
- Stability considerations
- Observed issues
Mihhail Osipchik
- GitHub: Awvyyy
- LinkedIn: Mihhail Osipchik