- About the Project
- Features
- Installation
- Configuration
- Usage
- Folder Structure
- Dependencies
- Reporting
- Contributing
- License
The Petstore API Testing With RestAssured Cucumber framework is an API testing solution for the Petstore API, utilizing RestAssured for API interactions, Cucumber for BDD (Behavior-Driven Development), and TestNG for test execution. This framework tests essential API functionalities, such as adding, updating, retrieving, and deleting pets.
- API Testing with RestAssured: Provides methods for
GET
,POST
,PUT
, andDELETE
requests. - Behavior-Driven Development: Uses Cucumber with Gherkin syntax to define scenarios in a human-readable format.
- Detailed Reporting: Generates HTML and PDF reports using ExtentReports for comprehensive test results.
- Test Automation: Tests include critical API functionality for the Petstore, including adding new pets, updating pet info, and verifying responses.
- Get Pet by ID: Retrieves pet information by ID and checks for a 200 response.
- Add New Pet: Adds a new pet to the store and verifies the response data.
- Update Pet Info: Updates existing pet details, confirming the status change.
- Delete Pet by ID: Deletes a pet by ID and validates the deletion response.
- Clone the repository:
git clone https://github.com/cihat-kose/petstore-api-testing-with-restassured-cucumber.git
- Open the project in IntelliJ IDEA:
- Go to File > Open and select the project folder.
- Ensure the project is imported as a Maven project.
- Install Plugins (optional for IntelliJ IDEA):
- Cucumber for Java and Gherkin plugins for Cucumber syntax support.
- Go to File > Settings > Plugins and search for the plugins to install.
- cucumber.properties: Configures Cucumber options. Located in
src/test/resources
. - extent.properties: Configures ExtentReports settings. Located in
src/test/resources
.extent.reporter.spark.start=true extent.reporter.spark.out=test-output/SparkReport/Spark.html extent.reporter.pdf.start=true extent.reporter.pdf.out=PdfReport.pdf
-
Run Tests:
- To run tests with TestNG, right-click on
TestRunnerExtentReport
in therunners
package and select Run. - Alternatively, use Maven from the command line:
mvn clean test
- To run tests with TestNG, right-click on
-
Generate Reports:
- Test results are generated in HTML (
test-output/SparkReport/Spark.html
) and PDF (PdfReport.pdf
) formats.
- Test results are generated in HTML (
petstore-api-testing-with-restassured-cucumber/
│
├── src/
│ └── test/
│ ├── java/
│ │ ├── features/ # Cucumber feature files
│ │ │ └── PetstoreAPITests.feature
│ │ ├── pages/ # API interaction classes
│ │ │ └── APIPage.java
│ │ ├── runners/ # TestNG runner classes
│ │ │ └── TestRunnerExtentReport.java
│ │ ├── stepDefinitions/ # Step definitions for Cucumber
│ │ └── PetstoreAPISteps.java
│ └── resources/
│ ├── cucumber.properties # Cucumber configuration
│ ├── extent.properties # ExtentReports configuration
│ ├── postman/ # Postman collection for API tests
│ │ └── Petstore API Test.postman_collection.json
│ └── testng.xml # TestNG suite configuration
├── target/ # Build output
└── pom.xml # Maven configuration file
Dependencies are managed in the pom.xml
file. Key dependencies include:
- RestAssured: For making HTTP requests to test the API.
- Cucumber Java & TestNG: Cucumber for BDD and TestNG for managing test execution.
- ExtentReports: For generating detailed HTML and PDF reports.
- SLF4J: Simple Logging Facade for Java, used for logging during testing.
Test reports are stored in test-output
and testReports
directories. Reports generated include:
- HTML Report: Located at
test-output/SparkReport/Spark.html
. - PDF Report: Available at
PdfReport.pdf
.
These reports include test results, system information, and details of each test scenario.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE
file for details.