How bhanjan03/apiautomation works
Project Type and Purpose
• This is an open-source Java-based API Automation Framework.
• Primary goal: enable writing, executing, mocking, and reporting REST API tests via RestAssured, TestNG, WireMock, Owner (config), and ExtentReports.
File Structure
• Top-level:
• pom.xml (Maven build & dependencies)
• README.md (architecture & usage)
• extent-test-report/ (generated HTML reports)
• src/main/java/com/apiautomationframework:
• config/ (Owner interfaces, ConfigFactory)
• constants/, enums/, exceptions/ (framework metadata & errors)
• models/pojo & models/builders (request/response data models & builder patterns)
• reports/ (ExtentReports integration: manager, logger, initialization)
• utils/ (AuthTokenManager, FakerUtils)
• src/test/java/com/apiautomationframework/tests:
• TestNG test classes (LoginTest, AdminTest, AccountTest, UserProfileTest)
• ParallelTestRunner/TestRunner
• src/test/java/com/apiautomationframework/wiremock:
• WireMock-based mock tests
• src/test/resources/config:
• config.properties (environment, credentials, timeout, headless, etc.)
Main Components
a. Test Runner Layer
• TestNG runner (ParallelTestRunner/TestRunner)
• BaseTest (report setup/teardown)
b. Test Cases
• LoginTest, AdminTest, AccountTest, UserProfileTest, APIWireMockTest
• Use custom annotations (@Authors, @CategoryType)
c. Configuration Manager
• FrameworkConfig/ConfigFactory (Owner)
• config.properties
d. API Client
• RestAssured module invoking HTTP calls
• AuthTokenManager for token handling
e. Mocking Service
• WireMock server for stubbed endpoints
f. Data Modeling
• POJOs (LoginRequest, LoginResponse, User)
• Builder classes (RequestBuilder, ResponseBuilder, TokenManager)
g. Reporting Engine
• ExtentReport, ExtentManager, ExtentLogger
• Generates extent-test-report HTML
h. Utilities
• FakerUtils for test data generation
Relationships & Data Flow
1. Test Runner initializes → loads configuration via ConfigFactory → BaseTest initializes ExtentReports
2. Test case begins → retrieves test data via FakerUtils or POJO builders
3. Test case invokes RestAssured client → uses AuthTokenManager if auth is needed
4. HTTP request goes to either:
– Real target API (via URL in config.properties)
– WireMock stub (for isolated/mock scenarios)
5. Response → mapped to POJO via ResponseBuilder → validated/asserted in test
6. ExtentLogger logs each step/result → ExtentReport updated
7. After all tests, ExtentReport flushes to extent-test-report/
Architectural Patterns & Principles
• Layered architecture: Test Runner → Tests → Client → Services (Real vs. Mock) → Reporting
• Builder Pattern for constructing requests/responses
• Factory Pattern for configuration (ConfigFactory)
• Custom annotations for metadata (authors/categories)
• Parallel execution for performance (TestNG parallel runner)
Essential Elements to Capture
• Separation of concerns: config vs. data modeling vs. execution vs. reporting
• Data flow: from test definition → HTTP request → response mapping → assertions
• Extensibility: builder patterns, custom annotations, WireMock hooks
• Parallelism: TestNG parallel runner interacting with shared report manager