This project is a comprehensive API testing framework designed to test and automate the API of the Swagger Petstore for the User, Pet, and Store models. Built using REST Assured, Java, TestNG, Maven, Jenkins, Git, and Extent Reports, it is designed to simplify API testing and reporting, ensuring efficient and reliable automated testing processes.
REST Assured: For simplified and efficient API testing.
Java: The core programming language for the framework.
TestNG: To manage test cases and generate reports.
Maven: For project build management and dependency management.
Jenkins: For continuous integration and continuous delivery (CI/CD).
Git: For version control.
Extent Reports: For generating detailed and visually appealing test reports.
-
Java Development Kit (JDK) 1.8 or higher
-
An IDE of your choice (Eclipse in my case)
-
Maven 3.9 or higher
-
Git
-
Jenkins
- Clone the repository:
git clone https://github.com/your-username/your-repo-name.git
- Navigate to the project directory:
cd your-repo-name
-
Update the pom.xml file with the necessary dependencies for REST Assured, TestNG, and Extent Reports, and more.
Dependencies you would need:
- rest-assured
- json-path
- json
- gson
- testng
- scribejava-apis
- Json-schema-validator
- Extent-Reports
- Apache POI
- Lombok
- java-faker(in case of generating random fake data)
-
Configure the TestNG XML file testng.xml to include your test classes and define the suite settings (currently Data Driven UserTest is included)
-
Set up Jenkins:
Create a new Jenkins job. Configure the job to pull from your Git repository. Add build steps to run your Maven commands.
To execute the test suite via Terminal/Cmd, run the following Maven command:
mvn test
After executing the tests, Extent Reports will generate a detailed report. You can find the report in the /reports
directory.
To set up continuous integration, configure your Jenkins job to run the tests automatically on every commit. This ensures that your API is continuously tested and any issues are detected early.
├── README.md
├── pom.xml
├── src
│ ├── main
│ │ ├── java
│ │ └── resources
│ └── test
│ ├── java
│ │ └── api
│ │ ├── endpoints
│ │ │ ├── PetEndpoint.java
│ │ │ ├── Routes.java
│ │ │ ├── StoreEndpoint.java
│ │ │ ├── UserEndpoint.java
│ │ │ └── UserEndpointViaRoutes.java
│ │ ├── payload
│ │ │ ├── PetPayload.java
│ │ │ ├── StorePayload.java
│ │ │ └── UserPayload.java
│ │ ├── test
│ │ │ ├── PetTestsViaProperties.java
│ │ │ ├── StoreTestsViaProperties.java
│ │ │ ├── UserTestsDataDriven.java
│ │ │ ├── UserTestsViaProperties.java
│ │ │ └── UserTestsViaRoutes.java
│ │ └── utilities
│ │ ├── DataProviders.java
│ │ ├── ExtentReportManager.java
│ │ └── XLUtility.java
│ └── resources
│ └── routes.properties
├── reports
│ ├── Test-Report - 2024.07.04.12.16.48.html
│ └── Test-Report - 2024.07.04.13.04.56.html
├── testData
│ ├── TestCases.xlsx
│ ├── Userdata.xlsx
│ ├── Storedata.xlsx
│ ├── Petdata.xlsx
└── testng.xml