How ch-akash/rest-assured-testng-framework works
Project type and purpose
• This is an API test-automation framework (not a user-facing service), built in Java with Maven, TestNG, and RestAssured.
• Its goal is to drive HTTP calls against a REST booking service, validate responses, and produce Allure reports.
File structure
• src/main/java/apis: encapsulates each endpoint (CreateBookingApi, GetBookingApi, etc.).
• src/main/java/http: BaseApi implements shared HTTP logic.
• src/main/java/config: loads properties (API base URL, credentials).
• src/main/java/constants: centralizes API path constants.
• src/main/java/pojo: request/response models.
• src/main/java/util: helpers for building requests and test data.
• src/main/java/listeners: TestNG listeners—AnnotationTransformer, RetryAnalyzer.
• src/test/java: TestNG test classes invoking the API classes.
• Root and CI files: Dockerfile, Jenkinsfile, GitHub workflows, pom.xml, suite XMLs.
Key insights from README
• TestNG drives test execution; RestAssured does HTTP/JSON; Maven orchestrates build/deps; Allure is the report engine.
• Two suite entry points: crud-tests.xml (CRUD) and suite.xml (full suite).
Main components
a. Test Runner Layer
• TestNG core engine
• suite XMLs (crud-tests.xml, suite.xml)
b. Test Layer
• Test classes (CRUDTests, CreateBookingApiTests, etc.)
c. API Abstraction Layer
• apis package (CreateBookingApi, GetBookingApi, UpdateBookingApi, DeleteBookingApi)
• http.BaseApi (handles HTTP setup, common headers, authentication)
• constants.ApiPaths
• util.ApiRequestHelper & TestDataHelper
d. Data Model Layer
• pojo.request (BookingDates, CreateBookingRequest)
• pojo.response (Booking, CreateBookingResponse)
e. Configuration Layer
• config.PropertyConfig & PropertyUtil reading config.properties
f. Reporting & Listeners
• listeners.AnnotationTransformer & RetryAnalyzer
• Allure TestNG listener (via pom.xml)
g. External Systems & Tools
• System under test (Booking REST API)
• CI/CD (GitHub Actions, Jenkins)
• Docker container environment
• Allure CLI for report serving
Relationships and interactions
• TestNG Runner reads suite XML → instantiates Test classes.
• Test classes call into API Abstraction Layer.
• API classes use PropertyConfig to fetch base-URL and credentials.
• BaseApi + RestAssured execute HTTP request against SUT.
• Responses are deserialized into POJOs.
• Test assertions compare POJOs to expectations (using TestDataHelper).
• Listeners hook into TestNG events for retry logic and annotation transformation.
• TestNG Allure listener collects test steps and results → Allure generates HTML/JSON.
• CI pipelines kick off mvn test, build Docker image, run tests, publish Allure reports.
Architectural patterns and design principles
• Layered architecture: separation of concerns (Tests, API clients, config, data models).
• Page-object-like pattern for REST endpoints (one class per endpoint).
• Centralized configuration and constants to avoid magic strings.
• Utility classes for reusability (request building, test data).
• TestNG listener pattern for cross-cutting concerns (retry, dynamic annotations).