feat: 重构测试框架 — 覆盖 6 端 (管理端 + 小程序 + 4 个移动端)

目录结构:
  tests/web/admin/       管理端 (Playwright)
  tests/web/mini_program/ 司机端小程序 (Playwright/微信 WebView)
  tests/app/driver_android/  司机安卓 (Appium)
  tests/app/shipper_android/ 货主安卓 (Appium)
  tests/app/driver_ios/      司机苹果 (Appium)
  tests/app/shipper_ios/     货主苹果 (Appium)

公共模块:
  tests/app/_shared.py       driver+ensure_logged_in 工厂
  tests/app/_base_page.py    App Page Object 基类

配置:
  test_config.yaml 拆分为 6 个独立 section + 货主账号
This commit is contained in:
xst
2026-07-15 14:02:08 +08:00
parent 4b4b83a2c0
commit 03e152baab
37 changed files with 823 additions and 727 deletions
+5 -1
View File
@@ -6,8 +6,12 @@ Usage:
from tests.config.test_config import load_config
config = load_config()
web_url = config["web"]["base_url"]
admin_url = config["admin"]["base_url"]
admin_phone = config["accounts"]["super_admin"]["phone"]
各端通过 fixture 直接引用对应 section:
def test_xxx(admin_config):
page.goto(admin_config["base_url"])
"""
from pathlib import Path
+100 -37
View File
@@ -1,9 +1,16 @@
# 运八网络货运平台 — 测试环境配置
# 数据来源: knowledge_base/00_project/project_profile.md
# 使用方式: from config.test_config import load_config
# 使用方式: from tests.config.test_config import load_config
#
# 覆盖端:
# Web: 管理端 admin / 司机端小程序 mini_program
# App: 司机安卓 driver_android / 货主安卓 shipper_android
# 司机苹果 driver_ios / 货主苹果 shipper_ios
# ── Web 管理端 ──
web:
# ═══════════════════════════════════════════════════════════════════
# ── 管理端 (Web/Playwright) ──
# ═══════════════════════════════════════════════════════════════════
admin:
base_url: "https://ybxcx.ynyun8.com:8000/admin"
api_base_url: "https://ybxcx.ynyun8.com:8000/"
timeout_seconds: 120
@@ -12,71 +19,127 @@ web:
browsers:
- chromium
- firefox
# WebKit 默认关闭(Windows 下问题较多),CI 环境可开启
viewport:
width: 1920
height: 1080
# 登录态复用(跳过图形验证码
# storage_state 文件保存了浏览器登录后的 cookies + localStorage
# 首次使用需手动登录一次生成,流程:
# 1. 运行: python tests/web/save_auth.py
# 2. 脚本打开浏览器 → 人工完成验证码登录 → 登录态自动保存
# 3. 后续执行用例时自动复用,无需重复登录
#
# skip_login: true → 加载已有的 storage_state,跳过登录步骤
# skip_login: false → 每次用例都通过 UI 执行完整登录流程
# 登录态复用: python tests/web/admin/save_auth.py 生成后自动跳过验证码
skip_login: true
storage_state_dir: "tests/web/auth" # 登录态存储目录
storage_state_dir: "tests/web/auth"
# ── App 移动端 ──
app:
# ═══════════════════════════════════════════════════════════════════
# ── 司机端小程序 (Web/Playwright,模拟微信 WebView) ──
# ═══════════════════════════════════════════════════════════════════
mini_program:
base_url: "https://ybxcx.ynyun8.com:8000/mini" # ⚠️ 请确认小程序 WebView 实际地址
timeout_seconds: 120
screenshot_on_failure: true
screenshot_on_step: false
browsers:
- chromium
# 模拟微信内置浏览器 UA
user_agent: "Mozilla/5.0 MicroMessenger/8.0.0"
viewport:
width: 375
height: 812
# 小程序本质是 WebView,同样支持 storage_state 复用
skip_login: true
storage_state_dir: "tests/web/auth"
# ═══════════════════════════════════════════════════════════════════
# ── 司机安卓端 (App/Appium) ──
# ═══════════════════════════════════════════════════════════════════
driver_android:
appium_host: "http://localhost:4723"
timeout_seconds: 120
screenshot_on_failure: true
platforms:
- android
# - ios # iOS 仅在 macOS CI 环境下开启
platform: android
skip_login: true # 手动登录一次后 noReset 自动复用
# 登录态复用(跳过图形验证码)
# Appium noReset=true 已确保 app 数据不重置,登录态持久保留
# 使用方式:手动启动 app 登录一次 → 后续用例自动跳过登录
#
# skip_login: true → 用例直接检查首页是否已登录态,跳过登录步骤
# skip_login: false → 每次用例都执行完整 UI 登录流程
device_name: "Android Emulator"
app_package: "com.arpa.ynchenggangdriver" # ⚠️ 请确认实际包名
app_activity: "com.arpa.ntocc.MainActivity" # ⚠️ 请确认实际启动 Activity
no_reset: true
new_command_timeout: 120
# ═══════════════════════════════════════════════════════════════════
# ── 货主安卓端 (App/Appium) ──
# ═══════════════════════════════════════════════════════════════════
shipper_android:
appium_host: "http://localhost:4723"
timeout_seconds: 120
screenshot_on_failure: true
platform: android
skip_login: true
android:
device_name: "Android Emulator"
app_package: "com.yunba.driver" # ⚠️ 请确认实际包名
app_activity: ".MainActivity" # ⚠️ 请确认实际启动 Activity
no_reset: true
new_command_timeout: 120
device_name: "Android Emulator"
app_package: "com.yunba.shipper" # ⚠️ 请确认实际包名
app_activity: ".MainActivity" # ⚠️ 请确认实际启动 Activity
no_reset: true
new_command_timeout: 120
ios:
device_name: "iPhone 15"
bundle_id: "com.yunba.driver" # ⚠️ 请确认实际 Bundle ID
no_reset: true
new_command_timeout: 120
# ═══════════════════════════════════════════════════════════════════
# ── 司机苹果端 (App/Appium,需 macOS) ──
# ═══════════════════════════════════════════════════════════════════
driver_ios:
appium_host: "http://localhost:4723"
timeout_seconds: 120
screenshot_on_failure: true
platform: ios
skip_login: true
device_name: "iPhone 15"
bundle_id: "com.arpa.ynchenggangdriver" # ⚠️ 请确认实际 Bundle ID
no_reset: true
new_command_timeout: 120
# ═══════════════════════════════════════════════════════════════════
# ── 货主苹果端 (App/Appium,需 macOS) ──
# ═══════════════════════════════════════════════════════════════════
shipper_ios:
appium_host: "http://localhost:4723"
timeout_seconds: 120
screenshot_on_failure: true
platform: ios
skip_login: true
device_name: "iPhone 15"
bundle_id: "com.yunba.shipper" # ⚠️ 请确认实际 Bundle ID
no_reset: true
new_command_timeout: 120
# ═══════════════════════════════════════════════════════════════════
# ── 测试账号 ──
# ═══════════════════════════════════════════════════════════════════
accounts:
super_admin:
phone: "super_admin"
password: "951260684NiAn.." # ⚠️ 若密码变更请同步修改
password: "951260684NiAn.."
role: "平台运营人员"
use_on: [admin]
team_leader:
phone: "13113113113"
password: "88888888"
role: "车队长"
use_on: [admin, mini_program]
driver:
phone: "15188888888"
password: "88888888"
role: "司机"
use_on: [mini_program, driver_android, driver_ios]
shipper:
phone: "13800000000" # ⚠️ 请确认实际货主账号
password: "88888888"
role: "货主"
use_on: [shipper_android, shipper_ios]
# ═══════════════════════════════════════════════════════════════════
# ── 报告 ──
# ═══════════════════════════════════════════════════════════════════
report:
logs_dir: "output/logs"
screenshots_dir: "output/screenshots"