# rajatt95/masterseleniumframework_bdd architecture

> Architecture diagram of the GitHub repository rajatt95/masterseleniumframework_bdd, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rajatt95/masterseleniumframework_bdd
- Repository: https://github.com/rajatt95/masterseleniumframework_bdd

## Overview

##### Project Identification & Overall Purpose
- The project is a test automation framework designed for Behavior-Driven Development (BDD) using Selenium WebDriver. It supports both UI and API tests, harnessing atomic tests concepts.
- It supports multiple test runners (TestNG, JUnit, CLI) and is built for scalable and maintainable automation with features like Dependency Injection, parallel execution, and CI/CD integration.

##### File Structure to Identify Main Components
- Maven Build & Configuration:
- At the root, the pom.xml file manages dependencies, plugin configurations (including parallel execution and browser instances), and build settings.
- Test Code Under src/test:
- The package “awesomecucumber” organizes the tests:
- /apis: Contains classes for API interactions (e.g., ApiRequest.java, CartApi.java) suggesting an API layer for setting the application state.
- /constants & /enums: Hold constant values and enumerations (FrameworkConstants.java, EndPoint.java, EnvType.java) to manage configuration and environment-specific settings.
- /context: Establishes the TestContext, possibly for dependency injection and sharing state across tests.
- /customtype: Defines custom data table/parameter types for Cucumber.
- /domainobjects: Models the business/domain data (BillingDetails, Product, etc.) to support clean data representation in tests.
- /factory: Includes DriverFactory and PageFactoryManager which are key to setting up Selenium WebDriver instances and page object creation.
- /hooks: Contains hooks (MyHooks.java) to handle pre/post test scenarios (e.g., screenshot on failure).
- /java_Mail_API: Provides functionality for sending email reports (attachments and configuration).
- /pages: Implements the Page Object Pattern with page classes such as BasePage, CartPage, etc.
- /runners: Contains multiple runner classes (MyJUnitRunnerTest.java, MyTestNGRunnerTest.java) for executing tests using different frameworks.
- /stepdefinitions: Maps human-readable Cucumber steps to executable code in various step definition classes.
- /utils: Provides utility classes for configuration loading, property management, JSON handling (JacksonUtils), and other helper functions.
- Test Resources:
- In src/test/resources, configuration files for multiple environments (int, prod, qa, stg) and Cucumber-specific configurations, along with feature files that drive the test scenarios.
- Additional Artifacts:
- The CucumberReports.zip and various PDF and image reports demonstrate integration with report generation tools.

##### Relationships and Interactions
- Test Runner → Step Definitions: The runner classes execute tests by triggering step definitions that implement Cucumber feature steps.
- Step Definitions → Page Objects / API Layer: Step definitions invoke methods in Page classes (for UI interactions using Selenium) as well as API classes (for backend state set-up using RestAssured or similar).
- Page Objects → DriverFactory: Page objects use driver instances provided by the DriverFactory to interact with browsers.
- Test Context & Dependency Injection: Shared objects (TestContext) are injected across step definitions to maintain state during tests.
- Utility Classes: Serve as shared libraries across all components—for logging, property/config loading (ConfigLoader, PropertyUtils), JSON processing, etc.
- Reporting: Integration with reporting modules collects screenshots (via hooks) and test results (zipped reports) for CI/CD consumption.

##### Architectural Patterns & Design Principles
- Page Object Model (POM): Clearly visible in the pages directory to encapsulate UI element interactions.
- Dependency Injection: The use of a TestContext and possibly DI frameworks to pass shared context between tests.
- Modularization: Segregating API interactions, UI tests, and utilities into dedicated packages promotes separation of concerns.
- Atomic Tests: Each test case is designed to perform single, verifiable actions ensuring maintainability.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Build & Configuration Layer
    subgraph "Build & Configuration"
        MBC("Maven Build & Configuration"):::build
        TR("Test Resources & Config"):::build
        MBC --> TR
    end

    %% Test Execution Layer
    subgraph "Test Execution Layer"
        TRNR("Test Runners"):::test
        SD("Step Definitions"):::test
        TC("Test Context & DI"):::test
        DPF("Driver & Page Factory"):::test
        POP("Page Objects (UI)"):::test
        API("API Testing Components"):::test
        CDT("Custom Data Types"):::test
        CONST("Constants"):::test
        ENUM("Enumerations"):::test
        DOM("Domain Objects"):::test
        UTIL("Utilities"):::util
        TH("Test Hooks"):::test

        TRNR -->|"triggers"| SD
        SD -->|"uses"| TC
        SD -->|"calls"| POP
        SD -->|"calls"| API
        SD -->|"uses"| CDT
        API -->|"manipulates"| DOM
        DPF --> POP
        CONST -->|"configures"| TC
        ENUM -->|"configures"| TC
        UTIL --> SD
        SD -->|"integrates"| TH
        TR -->|"supplies"| TC
        TR -->|"supplies"| UTIL
    end

    %% Reporting & Integration Layer
    subgraph "Reporting & Integration"
        ER("Email Reporting Module"):::report
        RA("Reporting Artifacts"):::report
        TH --> ER
        TH --> RA
    end

    %% Styles
    classDef build fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    classDef test fill:#aed6f1,stroke:#2874a6,stroke-width:2px;
    classDef util fill:#f9e79f,stroke:#af601a,stroke-width:2px;
    classDef report fill:#abebc6,stroke:#1e8449,stroke-width:2px;

    %% Click Events
    click MBC "https://github.com/rajatt95/masterseleniumframework_bdd/blob/master/pom.xml"
    click TR "https://github.com/rajatt95/masterseleniumframework_bdd/tree/master/src/test/resources"
    click TRNR "https://github.com/rajatt95/masterseleniumframework_bdd/tree/master/src/test/java/awesomecucumber/runners"
    click SD "https://github.com/rajatt95/masterseleniumframework_bdd/tree/master/src/test/java/awesomecucumber/stepdefinitions"
    click TC "https://github.com/rajatt95/masterseleniumframework_bdd/blob/master/src/test/java/awesomecucumber/context/TestContext.java"
    click DPF "https://github.com/rajatt95/masterseleniumframework_bdd/tree/master/src/test/java/awesomecucumber/factory"
    click POP "https://github.com/rajatt95/masterseleniumframework_bdd/tree/master/src/test/java/awesomecucumber/pages"
    click API "https://github.com/rajatt95/masterseleniumframework_bdd/tree/master/src/test/java/awesomecucumber/apis"
    click CDT "https://github.com/rajatt95/masterseleniumframework_bdd/tree/master/src/test/java/awesomecucumber/customtype"
    click CONST "https://github.com/rajatt95/masterseleniumframework_bdd/blob/master/src/test/java/awesomecucumber/constants/FrameworkConstants.java"
    click ENUM "https://github.com/rajatt95/masterseleniumframework_bdd/tree/master/src/test/java/awesomecucumber/enums"
    click DOM "https://github.com/rajatt95/masterseleniumframework_bdd/tree/master/src/test/java/awesomecucumber/domainobjects"
    click UTIL "https://github.com/rajatt95/masterseleniumframework_bdd/tree/master/src/test/java/awesomecucumber/utils"
    click TH "https://github.com/rajatt95/masterseleniumframework_bdd/blob/master/src/test/java/awesomecucumber/hooks/MyHooks.java"
    click ER "https://github.com/rajatt95/masterseleniumframework_bdd/tree/master/src/test/java/awesomecucumber/java_Mail_API"
    click RA "https://github.com/rajatt95/masterseleniumframework_bdd/blob/master/CucumberReports.zip"
```
