Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/osandadeshan/rest-assured-java-api-automation-demo
This project serves as a boilerplate for automating REST APIs across various environments using TestNG and the Rest Assured library.
https://github.com/osandadeshan/rest-assured-java-api-automation-demo
api-automation backend-automation java rest-api rest-api-automation rest-assured testng
Last synced: about 19 hours ago
JSON representation
This project serves as a boilerplate for automating REST APIs across various environments using TestNG and the Rest Assured library.
- Host: GitHub
- URL: https://github.com/osandadeshan/rest-assured-java-api-automation-demo
- Owner: osandadeshan
- License: mit
- Created: 2023-08-21T11:12:19.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-09-17T03:12:16.000Z (about 2 months ago)
- Last Synced: 2024-09-17T09:11:00.592Z (about 2 months ago)
- Topics: api-automation, backend-automation, java, rest-api, rest-api-automation, rest-assured, testng
- Language: Java
- Homepage:
- Size: 37.1 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# API Automation Using Rest Assured & TestNG
This project provides a template for automating REST API testing across multiple environments using TestNG and the Rest Assured library.
[![Rest Assured Java API Automation CI](https://github.com/osandadeshan/rest-assured-java-api-automation-demo/actions/workflows/rest-assured-java-ci.yml/badge.svg?branch=master)](https://github.com/osandadeshan/rest-assured-java-api-automation-demo/actions/workflows/rest-assured-java-ci.yml)
## Prerequisites
1. Java
2. Maven
3. IntelliJ IDEA## Project structure
```
.github/ # GitHub workflow configurations
logs/ # Log4j log files
reports/ # Extent HTML report files
src/
├── main/
│ ├── java/
│ │ └── com/
│ │ └── restassured/
│ │ └── example/
│ │ ├── Category.java
│ │ ├── HttpMethod.java
│ │ ├── constant/ # Project related constants including Application and Reporter contants
│ │ │ ├── ApplicationConstant.java
│ │ │ ├── AuthenticationConstant.java
│ │ │ ├── CommonConstant.java
│ │ │ └── ReporterConstant.java
│ │ ├── model/ # Model classes which represents the request JSON payload
│ │ │ ├── AuthenticationRequest.java
│ │ │ ├── BookingDates.java
│ │ │ ├── BookingRequest.java
│ │ ├── service/
│ │ │ ├── ExtentReportService.java # Extent report setup services
│ │ │ └── app/ # Application service classes
│ │ │ ├── AuthenticationService.java
│ │ │ └── BookingService.java
│ │ └── util/ # Utility methods
│ │ ├── AnnotationReader.java
│ │ └── FileReader.java
│ │ └── JsonFormatter.java
│ │ └── Log4jFilter.java
│ │ └── RestClient.java
│ │ └── TestListener.java
│ └── resources/ # Resource files for logging and reporting
│ ├── log4j2.xml
│ └── test-reporter.properties
├── test/
│ ├── java/
│ │ └── com/
│ │ └── restassured/
│ │ └── example/
│ │ └── test/
│ │ ├── constant/ # Test constants
│ │ │ └── TestCategory.java
│ │ ├── AuthTest.java # Authentication tests
│ │ ├── BaseTest.java # Base test class setup
│ │ ├── CreateBookingTest.java # API test for creating a booking
│ │ ├── DeleteBookingTest.java # API test for deleting a booking
│ │ ├── GetAllBookingsTest.java # API test for fetching all bookings
│ │ └── UpdateBookingTest.java # API test for updating a booking
│ └── resources/
│ └── env/ # Environment configurations
│ ├── dev.properties
│ ├── pre-prod.properties
│ ├── prod.properties
│ ├── qa.properties
│ └── uat.properties
│ └── regression-suite.xml # TestNG regression test suite configuration
│ └── smoke-suite.xml # TestNG smoke test suite configuration
target/ # Compiled code and build artifacts are stored here
.gitignore # Specifies files and directories to be ignored by Git
LICENSE # License information for the project
pom.xml # Maven configuration file for dependencies and build settings
README.md # Repository overview and instructions (This file)
```## ⚠️ Important: Steps to update the APIs
* Go to `com.restassured.example.util.RestClient`
* **Uncomment line 131** to enable your actual API functionality.
* Remove the **"TODO: "** comment, as it is no longer relevant## How to run tests
1. Using IntelliJ IDEA
* Go to Maven Profiles
* Select `dev`, `qa`, `uat`, `pre-prod` or `prod` Maven Profile as the environment
* Select the test classes on the `src/test/java` folder
* Right-click and click on `Run`2. Using Command Line
* To run the smoke test suite against the UAT environment`mvn clean test -Puat,smoke-test`
* To run the regression test suite against the QA environment
`mvn clean test -Pqa,regression-test`
**Note**: By default, if no Maven profiles are selected, the tests will be executed on the `dev` environment.
## License
[MIT License](https://opensource.org/licenses/MIT)## Copyright
Copyright 2024 [MaxSoft](https://maxsoftlk.github.io/).