How anhtester/restassuredtestng2023 works
Main Components Identification
a. API Test Suite Layer:
• Test Scripts: All tests are located under src/test. They are organized in different directories (e.g., Bai3_SendRequest_GETmethod, Bai5_POSTmethod, Bai7_Authentication_PUTmethod, etc.), which can be seen as functional modules or experiment labs.
• Test Data & Configuration: The test resources directory contains configurations (configs.properties, demo.properties) and test data (JSON files) for driving data-driven tests.
• TestNG Suites: Located in the “suites” folder, these XML files (e.g., SuiteAllureReport.xml, SuiteDemoListener.xml) define which tests to run and how to organize parallel execution/annotation-driven runs.
b. Core Automation Framework:
• Global Configurations: Found in the “globals” package, these classes (ConfigsGlobal.java, EndPointGlobal.java, TokenGlobal.java) centralize URL endpoints, tokens, and configuration values.
• Helpers: Under the “helpers” package are classes like JsonHelper.java, PropertiesHelper.java, and SystemHelper.java. They manage tasks such as JSON handling, properties file reading, and system-level utilities.
• Keywords and Spec Builder: In the “keywords” package, classes such as ApiKeyword.java and SpecBuilder.java implement the keyword-driven components and API specification builder indicating a more modular approach to writing tests.
• Reporting and Logging: The “reports” package includes AllureManager.java for reporting, and utility classes in “utils” (e.g., LogUtils.java) are used for logging. Additionally, log4j2 configuration files in resources support logging.
c. Supporting Components:
• Listeners and Extensions: The “listeners” package in tests shows additional support for TestNG event handling.
• Data Models: The “model” package includes POJOs that represent request and response structures for API testing.
Relationships and Interactions
• TestNG acts as the test runner that executes test classes in src/test. Each test case interacts with the core components.
• The test scripts import and use helper methods, global configurations, and keywords to construct and send HTTP requests with REST Assured.
• Test results are logged using the LogUtils and then reported via the AllureManager integrated in the reporting system.
• Test data is retrieved from the resources directory (properties and JSON files), and these are fed into the tests (often using the helpers).
• The suites (XML files) tie together tests, listeners, and parallel execution settings that determine the overall test workflow.
Architectural Patterns and Design Principles
• Layered Architecture: There’s a clear layering—configuration and utility layer (globals, helpers), a business logic layer (keywords, spec builders), and an execution layer (test scripts).
• Keyword-Driven Approach: The keywords package implies that some test steps are abstracted into reusable components.
• Separation of Concerns: Configurations, data models, test code, and utility classes are clearly separated to make maintenance easier.
Relevant Technologies and Frameworks
• REST Assured: For building and executing API requests.
• TestNG: For test execution and parallel test management.
• Allure Reporting: For generating friendly and detailed test reports (via the AllureManager).
• Log4j2: For application logging.
• Java: As the primary programming language, with Maven (pom.xml) for project management.
Final Detailed Suggestions
• Sub-components within each section. For example, under “Framework Core”, list classes like ConfigsGlobal, EndPointGlobal, and TokenGlobal.
• Use of external libraries (REST Assured, TestNG, Allure, Log4j2) and point out their integrations.
• Detail the flow: configuration and test data are read first, tests are executed (invoked by TestNG), tests invoke helper and keyword classes to build API requests, log/monitor the interactions, and finally report results via Allure.