How thangarajtk/restassured-api-automation works
Project type and purpose
• This is an API automation framework written in Java using Maven and TestNG.
• It uses Rest Assured (Groovy under the hood) to test RESTful services (GET, POST, PUT, PATCH, DELETE, etc.).
• It also integrates with JSON-Server, WireMock, Excel, Faker, Jira, and ExtentReports to facilitate end-to-end API testing, data-driven tests, mocking, and reporting.
File structure
• Top-level: Maven pom.xml, DockerFile, Checkstyle configs, a packaged JAR (jobportal-0.0.1-SNAPSHOT.jar) for the demo server, db.json for JSON-Server.
• src/main/java/com/automation:
• annotations, config, constants, enums, exceptions, listeners, models (builders & POJOs), reports, utils.
• FrameworkAnnotation.java marks custom annotations; ConfigFactory/FrameworkConfig load properties; ApiUtils wraps Rest Assured calls; ExtentManager/ExtentLogger manage HTML report; FakerUtils, ExcelUtils, JiraUtils, PropertyUtils, RandomUtils support test data & environment.
• src/test/java/com/automation:
• practice: exploratory tests against public APIs (reqres.in, ergast, JSON-Server, Postman Echo, WireMock).
• tests: core regression tests (job portal CRUD).
• src/test/resources: test data (Excel, JSON schemas, mock mappings), config.properties, WireMock standalone jar, log4j2.properties, TestNG suite (testng.xml).
README for additional insights
• Confirms quick start prerequisites: Java, IntelliJ, Maven, TestNG.
• Describes how to spin up JSON-Server (db.json) and the demo jobportal JAR.
• Mentions external URIs (reqres.in, ergast.com) and schema validation steps.
• Details WireMock usage and Docker build/push steps for the framework.
a. Main components:
1. Test Runner (TestNG + testng.xml)
2. Framework Core
• Configuration Module (ConfigFactory, FrameworkConfig, PropertyHelper)
• Request/Response Builders (RequestBuilder, ResponseBuilder)
• Utility Module (ApiUtils, FakerUtils, ExcelUtils, JiraUtils, AssertionUtils)
• Reporting Module (ExtentManager, ExtentLogger)
• Listeners & Retry Logic (Listeners, RetryFailedTests)
3. Test Suites
• practice/*
• tests/*
4. System-Under-Test (SUT)
• Local JSON-Server (db.json → http://localhost:3000)
• Demo JobPortal Spring Boot App (jobportal-…jar → localhost:5050)
• External REST APIs (reqres.in, ergast.com)
• WireMock Mock Server (standalone JAR + mappings)
5. Test Data & Artifacts
• Excel files, JSON schemas, XML schemas
• WireMock mappings & __files
6. CI/Docker
• DockerFile for packaging the test framework container
• pom.xml for build, checkstyle for code style
b. Relationships & interactions:
• Test Runner loads TestNG suite → invokes test classes → test methods call ApiUtils/RequestBuilder to formulate HTTP requests.
• ConfigModule reads config.properties → provides baseURL, authentication, ports.
• HTTP calls go to SUT: either local JSON-Server, JobPortal App, external APIs, or WireMock.
• Responses are passed to ResponseBuilder & AssertionUtils for validation (JSON/XML schema, status codes).
• Data-driven tests use ExcelUtils and FakerUtils for dynamic test data.
• JiraUtils can file bugs based on test outcomes.
• Listeners capture test events, trigger RetryFailedTests, and feed events to ExtentManager to produce HTML reports.
c. Architectural patterns:
• Layered pattern:
• Configuration → Request/Response Builders → API Execution → Assertions → Reporting
• Builder pattern for constructing requests and responses.
• Factory pattern in ConfigFactory.
• Singleton pattern in ExtentManager and constants (FCWithSingleton).
• Observer pattern via TestNG Listeners.
d. Key technologies:
• Java 11+, Maven, TestNG, Rest Assured (Groovy), WireMock, JSON-Server (node), ExtentReports, Apache POI (ExcelUtils), Faker, Jira API, Log4j2.