# anhtester/automation_android_appium2 architecture

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

- Interactive diagram: https://gitdiagram.com/anhtester/automation_android_appium2
- Repository: https://github.com/anhtester/automation_android_appium2

## Overview

##### Project Type and Purpose
- The project is a mobile test automation framework focused on “End To End Test Order Scenario on Android App called ‘Sauce labs’”.
- It uses Appium 2.x.x with Java and TestNG to run tests, employing a Page Object Model (POM) design pattern along with data-driven and fluent design principles.
- Its purpose is to automate UI testing on the Sauce Labs mobile app running on an Android emulator.

##### Analyzing the File Structure
- Top-level Files: You have Maven configuration (pom.xml), README, and various setup text files for Appium.
- src/main: Contains the core utility classes and framework components:
- keywords (e.g., MobileUI.java) which likely encapsulate mobile commands.
- listeners (e.g., ExtentManager.java and ExtentTestNGListener.java) for reporting and event handling.
- utils (e.g., JsonReader.java) for handling configuration/test data.
- resources/config with configuration properties.
- src/test: Contains test cases and related components:
- common/BaseTest.java sets up the testing framework.
- screens/ directory holds Page Object Model classes representing different screens like HomeScreen, LoginScreen, etc.
- testcases (e.g., DemoAppTest.java) that drive the test flows.
- resources includes the app APK and test data JSON files for data-driven testing.
- testng.xml: Orchestrates the execution of tests.

a. Main Components:
- Test Runner & Execution: Represent the TestNG layer, which uses testng.xml to trigger the tests.
- Keywords/Action Layer: Include a component for MobileUI (located in src/main/java/com/anhtester/keywords) which encapsulates common mobile actions.
- Configuration & Data Management: Represent config properties (from src/main/resources/config) and JSON test data (from src/test/resources/testdata). Also include the JsonReader utility.
- Reporting & Listeners: Identify Extent Manager and TestNG listeners that integrate with Extent and Allure Report systems.
- External Components: Include the Appium Server component (which communicates with the mobile emulator) and the Android Emulator itself.
- Build & Dependency Management: Represent Maven (pom.xml) which handles dependencies like Appium, java-client, TestNG, etc.

b. Relationships and Data Flow:
- The Test Runner (TestNG) initiates test cases (DemoAppTest and others in testcases).
- Test cases call methods on Page Object classes (screens) that represent different app screens.
- Page Objects interact with MobileUI keywords to send commands to the Appium server.
- The Appium server communicates with the Android studio emulator (with the Sauce Labs mobile app installed).
- Configuration and test data are loaded via the JsonReader (from properties and JSON files) and used within test cases.
- Throughout execution, listeners (e.g., ExtentTestNGListener) capture test events which are then logged and passed to reporting components (Allure/Extent Reports).

c. Architectural Patterns & Design:
- Use of the Page Object Model (POM) pattern to encapsulate UI element interactions.
- Data-driven design (usage of JSON test data).
- That the Fluent design approach likely leads to fluid method chaining for interactions.
- This separation (tests, POM, keywords, configuration, and utilities) is a best practice that isolates different concerns.

d. Relevant Technologies & Frameworks:
- Appium 2.x.x (for mobile automation)
- Java with Maven (for project build and dependency management)
- TestNG (as the test execution framework)
- Allure and Extent Reports (for reporting)
- Android Studio Emulator (as the test environment)
- Additionally, the java-client library and any underlying dependencies are significant.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Dependency
    subgraph "Build & Dependency"
        POM["Maven (pom.xml)"]:::build
    end

    %% Test Runner & Execution
    subgraph "Test Runner & Execution"
        TESTNG["TestNG Runner (testng.xml)"]:::runner
        BASE["BaseTest (Common)"]:::runner
        DEMO["DemoAppTest (Test Cases)"]:::runner
        TESTNG -->|"triggers"| BASE
        BASE -->|"initiates"| DEMO
    end

    %% Configuration & Data Management
    subgraph "Configuration & Data"
        CONFIG["Config File"]:::config
        TESTDATA["Test Data"]:::config
        JSONR["JsonReader Utility"]:::utility
        CONFIG -->|"loads"| JSONR
        TESTDATA -->|"loads"| JSONR
    end

    %% Page Object Layer
    subgraph "Page Object Layer"
        HS["HomeScreen"]:::pageobject
        LS["LoginScreen"]:::pageobject
        PS["ProductsScreen"]:::pageobject
        CS["CartScreen"]:::pageobject
        CHS["CheckoutScreen"]:::pageobject
        CCS["CheckoutCompleteScreen"]:::pageobject
        PAY["PaymentScreen"]:::pageobject
        RPS["ReviewProductScreen"]:::pageobject
    end

    %% Keywords/Action Layer
    subgraph "Keywords/Action Layer"
        MOBILE["MobileUI Keywords"]:::utility
    end

    %% Reporting & Listeners
    subgraph "Reporting & Listeners"
        EM["ExtentManager"]:::reporting
        ETL["ExtentTestNGListener"]:::reporting
    end

    %% External Components
    subgraph "External Components"
        APPIUM["Appium Server"]:::external
        EMULATOR["Android Emulator"]:::external
    end

    %% Connections between layers
    POM -->|"builds"| TESTNG
    JSONR -->|"supplies data to"| DEMO
    DEMO -->|"calls"| HS
    DEMO -->|"calls"| LS
    DEMO -->|"calls"| PS
    DEMO -->|"calls"| CS
    DEMO -->|"calls"| CHS
    DEMO -->|"calls"| CCS
    DEMO -->|"calls"| PAY
    DEMO -->|"calls"| RPS

    %% Page Objects interact with MobileUI Keywords
    HS -->|"invokes"| MOBILE

    %% MobileUI communicates with external components
    MOBILE -->|"sends commands"| APPIUM
    APPIUM -->|"communicates with"| EMULATOR

    %% Reporting connections
    DEMO -->|"reports to"| ETL
    DEMO -->|"logs to"| EM
    TESTNG -->|"integrates"| ETL

    %% CSS Classes for styling
    classDef runner fill:#ffe6e6,stroke:#cc0000,stroke-width:2px;
    classDef pageobject fill:#e6f9ff,stroke:#0066cc,stroke-width:2px;
    classDef utility fill:#e6ffe6,stroke:#339933,stroke-width:2px;
    classDef config fill:#f9e6ff,stroke:#cc33cc,stroke-width:2px;
    classDef reporting fill:#e6f7ff,stroke:#0099cc,stroke-width:2px;
    classDef build fill:#fff0e6,stroke:#ff6600,stroke-width:2px;
    classDef external fill:#fffde6,stroke:#cccc00,stroke-width:2px;

    %% Click Events for components
    click TESTNG "https://github.com/anhtester/automation_android_appium2/blob/main/testng.xml"
    click BASE "https://github.com/anhtester/automation_android_appium2/blob/main/src/test/java/com/anhtester/common/BaseTest.java"
    click DEMO "https://github.com/anhtester/automation_android_appium2/blob/main/src/test/java/com/anhtester/testcases/DemoAppTest.java"
    click HS "https://github.com/anhtester/automation_android_appium2/blob/main/src/test/java/com/anhtester/screens/HomeScreen.java"
    click LS "https://github.com/anhtester/automation_android_appium2/blob/main/src/test/java/com/anhtester/screens/LoginScreen.java"
    click PS "https://github.com/anhtester/automation_android_appium2/blob/main/src/test/java/com/anhtester/screens/ProductsScreen.java"
    click CS "https://github.com/anhtester/automation_android_appium2/blob/main/src/test/java/com/anhtester/screens/CartScreen.java"
    click CHS "https://github.com/anhtester/automation_android_appium2/blob/main/src/test/java/com/anhtester/screens/CheckoutScreen.java"
    click CCS "https://github.com/anhtester/automation_android_appium2/blob/main/src/test/java/com/anhtester/screens/CheckoutCompleteScreen.java"
    click PAY "https://github.com/anhtester/automation_android_appium2/blob/main/src/test/java/com/anhtester/screens/PaymentScreen.java"
    click RPS "https://github.com/anhtester/automation_android_appium2/blob/main/src/test/java/com/anhtester/screens/ReviewProductScreen.java"
    click MOBILE "https://github.com/anhtester/automation_android_appium2/blob/main/src/main/java/com/anhtester/keywords/MobileUI.java"
    click CONFIG "https://github.com/anhtester/automation_android_appium2/blob/main/src/main/resources/config/config.properties"
    click TESTDATA "https://github.com/anhtester/automation_android_appium2/tree/main/src/test/resources/testdata"
    click JSONR "https://github.com/anhtester/automation_android_appium2/blob/main/src/main/java/com/anhtester/utils/JsonReader.java"
    click EM "https://github.com/anhtester/automation_android_appium2/blob/main/src/main/java/com/anhtester/listeners/ExtentManager.java"
    click ETL "https://github.com/anhtester/automation_android_appium2/blob/main/src/main/java/com/anhtester/listeners/ExtentTestNGListener.java"
    click POM "https://github.com/anhtester/automation_android_appium2/blob/main/pom.xml"
```
