How abu-sithik/rest_assured-automation-framework works
Project type and purpose
• This is an open-source Java/Maven API testing automation framework.
• It leverages RestAssured for HTTP calls, TestNG for test orchestration, and ExtentReports for reporting.
Core components
a. Configuration & Resources
• constants.properties (base URL, DB/SSH creds)
• TestNG.xml (test suite definitions)
• pom.xml (dependencies: RestAssured, TestNG, ExtentReports)
b. Utilities Layer
• DBConnection (singleton, MySQL)
• SshConnectionManager / Helper (SSH sessions, remote commands, CSV/JSON helpers)
c. Base API Entities
• One class per endpoint in com.restfulbooker.apitest.baseAPI (e.g., Auth.java)
• Each defines path, headers, body, HTTP method
d. Action & Interface Layer
• HttpOperation & ValidatorOperation (enums for CRUD and assertion types)
• IApi interface (blueprint for API operations)
• API.java (implements IApi, wraps RestAssured core calls)
e. TestNG Orchestration
• Test classes in src/test/java (e.g., LoginTest)
• TestNG runner invokes tests, passes Method references for dynamic reporting
f. Listeners & Reporting
• AnnotationTransformer, Retry, TestStatusListener (hook into TestNG events)
• ExtentManager & ExtentTestManager (manage ExtentReports lifecycle and thread-safe tests)
• ExtentReportResults.html (output)
g. External Systems
• Target RESTful service (e.g., restful-booker API)
• MySQL database (if DBConnection is used)
• SSH servers (if remote setup via SSH)
Relationships and data flows
• TestNG Runner triggers a Test case → Test class calls BaseAPI class → BaseAPI uses API.java (RestAssured) with HttpOperation to make HTTP request → Response flows back to API, passed to ValidatorOperation for assertions.
• During the test execution TestNG listeners intercept events (onStart, onTestSuccess, onTestFailure) → Hand off to ExtentManager / ExtentTestManager → Write entries into ExtentReports HTML.
• Utilities (DBConnection, SSH) may be invoked from tests or framework hooks (e.g., to set up data).
• Configuration properties feed into BaseAPI initialization and Utilities.
Architectural patterns & principles
• Layered architecture: Utilities → Core API library → Actions & Interfaces → Tests → Reports.
• Interface-implementation segregation: IApi defines contract, API.java delivers implementation.
• Singleton pattern: DBConnection ensures single DB connection.
• Enum-based operation definitions: HttpOperation / ValidatorOperation centralize constants.
• Observer/Listener pattern: TestNG listeners observe test events and report accordingly.