BitFun 多平台桌面应用自动化测试框架(独立测试仓)。OH 基于 Hypium + hdc;Mac/Win 规划中。
- Python 3.10.x(推荐 3.10.11,见
.python-version) - OH 平台:Windows 宿主机 + hdc + 鸿蒙 PC + 已安装 BitFun
- Mac/Win 平台:Phase 1 暂未实现(预期 skip)
# 创建虚拟环境
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)。
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
- bundleName:
aw/oh.py中BITFUN_BUNDLE = "com.huawei.BitFun"(已通过 hdc 确认) - OH 选择器登记表:
resource/selectors_oh.yaml(main_shell等 key;UiViewer 确认后confirmed: true) - 意图表(Excel):
docs/smoke-intents.csv· AI 生成用例:docs/AI-GENERATE-TESTCASE.md - 设备 SN:
config/user_config.xml中<device sn="..." />,单设备可留空
| 问题 | 排查 |
|---|---|
hdc list targets 无输出 |
检查 USB 连接、驱动、hdc 是否在 PATH;详见 setup-windows-hdc.md |
pytest: error: --platform |
--platform 参数必填,值为 oh、mac 或 win |
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/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 |
- BitFun 产品仓库(独立)— TODO: 补充仓库链接
-
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、无平台子目录、无弱化断言)