How deepika5reddy/java-restassured works
Project Type and Purpose
• This is a Java-based REST API test automation framework. It uses Maven for build/dependency management, TestNG as the test runner, and RestAssured to issue HTTP requests and assert API responses. Its purpose is to organize and execute automated API test cases (GET calls in the current scope) and integrate seamlessly into CI/CD pipelines (e.g., Jenkins).
File Structure Analysis
• Top level
• pom.xml: Maven project descriptor (dependencies, build plugins).
• Jenkinsfile: Defines the CI pipeline steps.
• README.md: Documents how to build and run tests.
• config.properties: Global test configuration.
• src/main/java
• core/: Shared constants/enums (e.g., StatusCode).
• utils/: Utility classes for reading JSON (JsonReader), properties (PropertyReader), and soft assertions (SoftAssertionUtil).
• src/test/java
• userManagement/: Test classes for API endpoints (getUsers.java, getPostmanEcho.java).
• Basics/: Example test cases (reverse string, etc.)—likely sample/experimental tests.
• resources
• TestData/testdata.json: External test data file.
• TestSuites/*.xml: TestNG suite definitions (GroupSuite, SmokeSuite).
Key Components
a. Source Code Repository (GitHub)
• Contains pom.xml, source, resources, Jenkinsfile.
b. Developer Environment (IDE + Git + Maven CLI)
• Checkout, code edit, mvn clean test locally.
c. Build & CI Server (Jenkins)
• Pulls code, runs Maven build, triggers TestNG suites.
d. Build Tool (Maven)
• Resolves dependencies (RestAssured, TestNG), compiles code, executes tests.
e. Test Runner (TestNG)
• Reads suite XMLs, instantiates test classes under src/test/java.
f. Core & Utility Modules
• core.StatusCode, utils.JsonReader, utils.PropertyReader, utils.SoftAssertionUtil.
g. Test Scripts
• userManagement.getUsers, userManagement.getPostmanEcho (issue HTTP GETs via RestAssured).
h. Test Data & Configuration
• config.properties; TestData/testdata.json; suite XML files.
i. External API Under Test
• Third-party or internal REST endpoints (e.g., /users, echo endpoints).
j. Test Reports & Logs
• TestNG HTML/XML reports; JUnit XML for Jenkins.
Relationships and Data Flows
• Developer → Git push → Jenkins
• Jenkins → mvn clean test → Maven
• Maven → compile src/main/java & src/test/java → produce test runner artifacts
• TestNG → read test suite XML → invoke Test Classes
• Test Classes → call RestAssured → send HTTP requests to External API
• Responses → validated using StatusCode enum + SoftAssertionUtil → results collected
• TestNG → generate reports → Jenkins archive/publish
Architectural Patterns & Principles
• Layered structure:
• Configuration layer (config.properties, suite XMLs)
• Utility layer (JsonReader, PropertyReader, SoftAssertionUtil)
• Core definitions (StatusCode)
• Test layer (TestNG test classes)
• Separation of concerns: Test definitions do not manage JSON parsing or property loading directly—they delegate to util classes.
• CI/CD readiness: Jenkinsfile codifies build and test steps.
• Extensibility points:
• More HTTP methods by creating new test classes under packages.
• Custom reporters or listeners via TestNG plugin configuration in pom.xml.