This project offers a framework and tools for automated API testing using Java, REST Assured, and TestNG, following Data-Driven Testing (DDT) best practices and employing the Service Object Model design pattern.
This suite of tests is focused on validating and testing CRUD (Create, Read, Update, Delete) operations related to user management within the Swagger Petstore API (Base URL: https://petstore.swagger.io). Specifically, the tests interact with the following endpoints:
- Create User (POST): Endpoint URL: https://petstore.swagger.io/v2/user
- Get User (GET): Endpoint URL: https://petstore.swagger.io/v2/user/{username}
- Update User (PUT): Endpoint URL: https://petstore.swagger.io/v2/user/{username}
- Delete User (DELETE): Endpoint URL: https://petstore.swagger.io/v2/user/{username}
These tests are designed to ensure the functionality and correctness of these user management endpoints provided by the Swagger Petstore API. They interact with the defined URLs in the Routes class to perform comprehensive testing of user-related functionalities.
- JDK 21
- Lombok 1.18.30
- REST Assured 5.3.2
- TestNG 7.8.0
- pom.xml: Maven configuration file specifying project dependencies.
- run.bat: Batch script for execution in a Windows environment.
- Routes.java: Defines URLs for CRUD operations related to user management.
- UserEndPoints.java: Encapsulates HTTP requests for user-related API endpoints.
- User.java: Class representing user data for API operations.
- DDTests.java: Test class implementing Data-Driven Testing (DDT) methodologies.
- testng.xml: TestNG configuration file for test execution.
- UserTests.java: Contains test methods to perform CRUD operations on user endpoints using generated/fake data.
- DataProviders.java: Utility class providing data for tests.
- ExtentReportManager.java: Manages Extent reports for test execution.
- XLUtility.java: Utility class for handling Excel file operations.
- log4j2.xml: Configuration file for Log4j2 for logging purposes.
- Userdata.xlsx: Excel file containing user data used in testing.
-
Clone this repository:
git clone https://github.com/carlosvagnoni/JavaRestAssuredTestNG.git cd JavaRestAssuredTestNG
-
Compile the project:
mvn clean compile
- Userdata.xlsx can be modified to add any necessary data. The file accepts an arbitrary amount of data, accommodating any quantity of entries.
Run all the tests:
mvn test
Open report:
start "" "reports\Test-Report.html"
NOTE:
- Set up the respective environment variables beforehand.
- On Windows environments, you can directly execute the
run.bat
file.
If you have any questions or suggestions, feel free to contact me through my social media accounts.
Thank you for your interest in this project!