How rajatt95/masterseleniumframework_bdd works
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.