Skip to content

Repository files navigation

BitFun E2E Test Framework

BitFun 多平台桌面应用自动化测试框架(独立测试仓)。OH 基于 Hypium + hdc;Mac/Win 规划中。

Prerequisites

  • Python 3.10.x(推荐 3.10.11,见 .python-version
  • OH 平台:Windows 宿主机 + hdc + 鸿蒙 PC + 已安装 BitFun
  • Mac/Win 平台:Phase 1 暂未实现(预期 skip)

Quick start

# 创建虚拟环境
py -3.10 -m venv .venv
.venv\Scripts\activate          # Windows
# source .venv/bin/activate     # macOS/Linux

# 安装依赖
pip install -r requirements.txt

# OH — 确认设备连接
hdc list targets

# 运行测试
pytest testcases/ --platform=oh -m "oh or all" -v

⚠️ 首次运行前需用 UiViewer 确认控件选择器(见 Configuration)。

Directory layout

bitfun_test/
├── pytest.ini                 # markers: oh, mac, win, all, smoke
├── conftest.py                # --platform option, app fixture, mark filtering
├── main.py                    # thin wrapper → pytest
├── config/
│   └── user_config.xml        # usb-hdc device config
├── testcases/                 # pytest cases (test_*.py, no platform subdirs)
│   └── test_s01_claw_chat_smoke.py        # OH 冒烟(含启动+会话+发送)
├── aw/
│   ├── __init__.py            # get_app()
│   ├── base.py                # AppBase protocol
│   ├── oh.py                  # OhApp (Hypium + hdc)
│   └── desktop.py             # DesktopApp (mac/win stub, Phase 1 skip)
├── resource/
│   └── selectors_oh.yaml      # OH 控件 text 登记表(意图 / 用例引用 key)
├── reports/                   # gitignored
├── docs/
│   ├── AGENT-RULES.md
│   ├── REFACTOR-EXECUTION.md
│   ├── AI-EXECUTION-BRIEF.md
│   ├── smoke-intent-table.md
│   ├── smoke-intents.csv      # 冒烟意图主表(Excel 打开编辑)
│   ├── smoke-intents-README.md
│   ├── intent-driven-hypium.md
│   ├── AI-GENERATE-TESTCASE.md
│   ├── e2e-change-rules.md
│   └── setup-windows-hdc.md
├── requirements.txt
├── .python-version
└── .gitignore

Configuration

  • bundleNameaw/oh.pyBITFUN_BUNDLE = "com.huawei.BitFun"(已通过 hdc 确认)
  • OH 选择器登记表resource/selectors_oh.yamlmain_shell 等 key;UiViewer 确认后 confirmed: true
  • 意图表(Excel)docs/smoke-intents.csv · AI 生成用例docs/AI-GENERATE-TESTCASE.md
  • 设备 SNconfig/user_config.xml<device sn="..." />,单设备可留空

Troubleshooting

问题 排查
hdc list targets 无输出 检查 USB 连接、驱动、hdc 是否在 PATH;详见 setup-windows-hdc.md
pytest: error: --platform --platform 参数必填,值为 ohmacwin
ModuleNotFoundError: hypium 确认虚拟环境已激活,pip install -r requirements.txt;若 pip 找不到包,尝试华为 PyPI 镜像
用例启动应用失败 确认 BITFUN_BUNDLE 为真实值;确认 BitFun 已安装在鸿蒙 PC 上
控件定位失败 UiViewer 确认后更新 resource/selectors_oh.yaml
Mac/Win 测试 skip Phase 1 预期行为;DesktopApp 尚未实现

Docs

文档 说明
docs/intent-driven-workflow.md 意图驱动端到端说明(写意图 → AI 生成 → 执行)
docs/smoke-intents.csv 冒烟意图表(Excel 维护)
docs/smoke-intents-README.md 意图表列说明
docs/AI-GENERATE-TESTCASE.md 给 AI 的生成用例 Prompt
docs/smoke-intent-table.md 意图索引(指向 CSV + 流程)
docs/intent-driven-hypium.md 三层分工简版
docs/AGENT-RULES.md Agent 硬性规则(最高优先级)
docs/e2e-change-rules.md 改测试规则
docs/setup-windows-hdc.md Windows 安装 hdc

Related

  • BitFun 产品仓库(独立)— TODO: 补充仓库链接

Phase A 完成检查清单

  • pytest.ini + conftest.py 多平台 mark 基础设施
  • aw/base.py + aw/oh.py + aw/desktop.py + aw/__init__.py
  • OH 冒烟:testcases/test_s01_claw_chat_smoke.py(含启动、Claw 会话、输入发送)
  • docs/AGENT-RULES.md 与 pytest 入口一致
  • BITFUN_BUNDLE 与 selector 与迁移前一致
  • 未做禁止项(无 WebDriverIO、无平台子目录、无弱化断言)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages