Files
smart-management-auto-test/zhyy/test_case/README_RUN_TESTS.md
qiaoxinjiu 6994b185a3 addproject
2026-01-22 19:10:37 +08:00

97 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 测试执行说明
## 统一测试执行工具
使用 `run_tests.py` 可以方便地执行各种测试用例。
## 安装依赖
```bash
pip install pytest
pip install pytest-allure-adaptor # 或 allure-pytest
pip install allure-python-commons
```
## 使用方法
### 1. 运行所有测试用例
```bash
python run_tests.py --all
```
### 2. 按 Allure Feature 标签运行
```bash
python run_tests.py --feature "深圳采购工作台采购订单页面"
```
### 3. 按 Allure Story 标签运行
```bash
python run_tests.py --story "验证采购工作台采购订单页面列表查询"
```
### 4. 按目录运行
```bash
python run_tests.py --dir "接口/SZPurchase"
```
### 5. 按文件运行
```bash
python run_tests.py --file "接口/SZPurchase/PurchaseOrderManage.py"
```
### 6. 按关键字运行(匹配文件名或类名)
```bash
python run_tests.py --keyword "purchase"
```
### 7. 按 pytest 标记运行
```bash
python run_tests.py --marker "smoke"
```
### 8. 生成并打开 Allure 报告
```bash
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/`
## 查看报告
生成报告后,可以使用以下命令打开:
```bash
allure open reports/allure-report
```
或者直接使用 `--open` 参数自动打开。