1.9 KiB
1.9 KiB
测试执行说明
统一测试执行工具
使用 run_tests.py 可以方便地执行各种测试用例。
安装依赖
pip install pytest
pip install pytest-allure-adaptor # 或 allure-pytest
pip install allure-python-commons
使用方法
1. 运行所有测试用例
python run_tests.py --all
2. 按 Allure Feature 标签运行
python run_tests.py --feature "深圳采购工作台采购订单页面"
3. 按 Allure Story 标签运行
python run_tests.py --story "验证采购工作台采购订单页面列表查询"
4. 按目录运行
python run_tests.py --dir "接口/SZPurchase"
5. 按文件运行
python run_tests.py --file "接口/SZPurchase/PurchaseOrderManage.py"
6. 按关键字运行(匹配文件名或类名)
python run_tests.py --keyword "purchase"
7. 按 pytest 标记运行
python run_tests.py --marker "smoke"
8. 生成并打开 Allure 报告
python run_tests.py --all --report --open
快捷方式(Windows)
run_all.bat- 运行所有测试用例run_purchase.bat- 运行采购相关测试用例
参数说明
--all: 运行所有测试用例--feature <name>: 按allure feature标签运行--story <name>: 按allure story标签运行--dir <path>: 按目录运行(相对于TestCase目录)--file <path>: 按文件运行(相对于TestCase目录)--keyword <keyword>: 按关键字运行--marker <marker>: 按pytest标记运行--report: 生成Allure报告--open: 打开Allure报告--no-report: 不生成Allure报告
报告位置
- Allure结果:
reports/allure-results/ - Allure报告:
reports/allure-report/
查看报告
生成报告后,可以使用以下命令打开:
allure open reports/allure-report
或者直接使用 --open 参数自动打开。