How yanchunhuo/automationtest works
Project Type and Purpose
• This is a unified test automation framework supporting:
– API tests (via pytest + requests)
– Web UI tests (via pytest + selenium)
– Mobile App UI tests (via pytest + Appium, covering Android, iOS, Chrome on mobile, Windows)
– Performance tests (via Locust)
• It provides reusable base/client libraries, configuration management, page-object modules, test case definitions, and report generation.
High-Level Components
a. Test Orchestrators (CLI entry points)
– run_api_test.py
– run_web_ui_test.py
– run_app_ui_test.py
– run_app_ui_monkey_test.py
– start_locust_master.sh / start_locust_slave.sh
– generate_*_test_report.py
b. Configuration Layer
– config/*.conf & project-specific config under config/demoProject
– pojo/*_config.py classes that load/hold config
– init/* modules that bootstrap each test type (init/api, init/web_ui, etc.)
c. Core Libraries
– base/ (foundation classes for API, UI, performance)
– common/ (shared utilities: HTTP client, database clients, image tools, encryption, messaging, etc.)
– common_projects/ (project-specific business logic abstractions)
d. Test Assets
– cases/ (pytest test modules organized by type and project)
– page_objects/ (Page-Object Model definitions for UI tests)
– models/ (SQLite DB models for session or state persistence)
– test_data/ (static JSON or data files)
– packages/ (mobile app binaries & installers)
e. External Services & Tools
– Target system under test: API endpoints, Web applications, Mobile apps
– Selenium server, Appium server, Locust master/slave
– Databases: MySQL / Oracle / SQLite / Redis / Memcached
– Allure server for report hosting
– External message queues (Aliyun MNS, Zookeeper)
f. Reporting & Logging
– logs/test.log
– output/ (Allure result directories)
– generate_*_test_report.py scripts
Relationships & Data Flows
• The runner scripts read config files, invoke init modules, and launch pytest with the specified cases/ directory.
• During test execution, pytest loads fixtures, uses base/ and common/ libraries to send HTTP requests or drive browsers/devices via Selenium/Appium.
• UI tests rely on page_objects/ to locate elements and execute interactions.
• Test data flows from test_data/ into test cases and may write state to models/ (SQLite) or external DBs.
• Performance tests spawn Locust clients that hit the target API/web endpoint.
• All test logs and results are collected under logs/ and output/.
• **generate_*_test_report.py** reads the output, invokes Allure to build HTML reports, and serves them.
Architectural Patterns & Principles
– Layered Architecture: separation of test orchestration, configuration loading, core libraries, and test assets.
– Plugin-based with pytest: test discovery, fixtures, markers, parallel execution via pytest-xdist.
– Page-Object Model (POM) for UI tests: clear separation of element definitions and test logic.
– Factory/Client Abstraction in base/api and base/app_ui: one client per project per platform.
– Singleton/Configuration pattern: pojo/*_config.py centralizes config parsing.
– Modularization: common code in common/, project‐specific overlays in common_projects/.