Skip to main content

Airtest 并行测试工具

Project description

Hairtest

Airtest 并行测试工具 - 支持多设备并行执行测试用例

特性

  • 🚀 多设备并行执行 - 支持多台Android设备同时运行测试
  • 📱 智能负载均衡 - 自动分配测试任务到可用设备
  • 📝 多种用例格式 - 支持单文件、目录、YAML用例集
  • 🔄 失败重试机制 - 支持断点续跑和失败用例重试
  • 📊 详细测试报告 - 生成JSON格式的测试结果报告
  • 🛠️ 简单易用 - 一条命令即可开始测试

构建包

python setup.py sdist bdist_wheel

# 上传到 PyPI 需要apitoken
twine upload dist/*

开发

cd hairtest
python cli.py Tests/TmapiClient/testsuites/core.yml
python cli.py Tests/TmapiClient/testsuites/core.yml --devices device1 --mode

安装地址https://pypi.org/project/hairtest/

pip install hairtest
# 国内镜像可能没有,指定官网
pip install --index-url https://pypi.org/simple/ hairtest

# 开发模式安装
pip install -e .

快速开始

基本使用

# 执行单个测试文件
hairtest Tests/TmapiClient/testAICase/ai_test.py

# 执行测试目录(自动扫描所有 *_test.py 文件)
hairtest Tests/TmapiClient/testAICase/

# 执行 YAML 用例集
hairtest Tests/TmapiClient/testsuites/core.yml

高级使用

# 指定设备执行
hairtest core.yml --devices MDX0220918025508

# 多设备并行
hairtest core.yml --devices MDX0220918025508 YWT0222A10000129

# 兼容模式(每个设备执行所有用例)
hairtest core.yml --mode

# 失败重试(基于之前的测试数据)
hairtest core.yml --retry-data 1753498757687_data.json

# 组合使用
hairtest core.yml --devices MDX0220918025508 YWT0222A10000129 --mode --retry-data data.json

参数说明

参数 简写 说明
test_path - 测试用例路径(必需)
--devices -d 指定设备列表,多个设备用空格分隔
--mode -m 兼容模式:多台设备并行,单设备脚本串行
--retry-data -r 失败重试:指定已运行的测试数据文件
--version -v 显示版本信息
--help -h 显示帮助信息

支持的文件类型

1. 单个测试文件

文件名必须以 _test.py 结尾:

ai_login_test.py
hotel_search_test.py

2. 测试目录

自动扫描目录下所有 *_test.py 文件:

Tests/
├── login_test.py
├── search_test.py
└── booking_test.py

3. YAML 用例集

支持自定义测试用例配置:

config:
    author: 王彦青
    create_time: '2022-05-25'
testcases:
  登录测试:
      testcase: Tests/TmapiClient/testAICase/ai_login_test.py
  搜索测试:
      testcase: Tests/TmapiClient/testAICase/ai_search_test.py
  预订测试:
      testcase: Tests/TmapiClient/testAICase/ai_booking_test.py

运行模式

负载均衡模式(默认)

测试用例平均分配到各个设备,每个用例只执行一次:

设备A: test1.py, test3.py
设备B: test2.py, test4.py

兼容模式(--mode)

每个设备都执行所有测试用例:

设备A: test1.py, test2.py, test3.py, test4.py
设备B: test1.py, test2.py, test3.py, test4.py

测试报告

执行完成后会在 reports/ 目录生成:

  • {timestamp}_data.json - 详细的测试结果数据
  • {timestamp}_logs/ - 各设备的测试日志

开发

# 克隆项目
git clone https://github.com/yourusername/hairtest.git
![img_1.png](img_1.png)cd hairtest

# 开发模式安装
pip install -e .
# 运行测试
hairtest Tests/TmapiClient/testsuites/core.yml

依赖

  • Python >= 3.7
  • airtest >= 1.3.0
  • gevent
  • pyyaml
  • jinja2
  • requests

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

更新日志

v1.0.0

  • 初始版本发布
  • 支持多设备并行测试
  • 支持多种用例格式
  • 支持失败重试机制

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hairtest-1.0.3.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hairtest-1.0.3-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file hairtest-1.0.3.tar.gz.

File metadata

  • Download URL: hairtest-1.0.3.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for hairtest-1.0.3.tar.gz
Algorithm Hash digest
SHA256 08e4bdf1183ed90b0296932b808373d10c3f02acb1e7d3528a358c97311abff3
MD5 187dbe2fa89702008ee2f6dbda2d72f5
BLAKE2b-256 e37a3b3f47892b196cef59eb202a7027e95da6daf84e0c33e1bbe4a88cecdd8f

See more details on using hashes here.

File details

Details for the file hairtest-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: hairtest-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for hairtest-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 640365aac3dfc8bbee03dc2c3f9173e9539bc9e0ac97b716c6debe33141d6d4a
MD5 0d000250695f4b9967d682de71248fc6
BLAKE2b-256 795fffa76056c8dbf39616518aa1c8fe687b6bc7597db868a89ee952ce19b3cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page