105 lines
2.5 KiB
Markdown
105 lines
2.5 KiB
Markdown
# E2E测试项目
|
|
|
|
## 项目概述
|
|
|
|
本项目使用Python + Playwright框架对Novalon管理系统进行端到端测试。
|
|
|
|
## 技术栈
|
|
|
|
- **Python**: 3.9+
|
|
- **Playwright**: 1.40+
|
|
- **Pytest**: 7.0+
|
|
- **Allure**: 测试报告
|
|
|
|
## 项目结构
|
|
|
|
```
|
|
e2e_tests/
|
|
├── __init__.py
|
|
├── conftest.py # Pytest配置和fixtures
|
|
├── pytest.ini # Pytest配置文件
|
|
├── requirements.txt # Python依赖
|
|
├── config/
|
|
│ ├── __init__.py
|
|
│ └── settings.py # 配置管理
|
|
├── pages/
|
|
│ ├── __init__.py
|
|
│ ├── base_page.py # 基础页面类
|
|
│ ├── auth_page.py # 认证相关页面
|
|
│ ├── user_page.py # 用户管理页面
|
|
│ ├── role_page.py # 角色管理页面
|
|
│ └── dictionary_page.py # 字典管理页面
|
|
├── api/
|
|
│ ├── __init__.py
|
|
│ ├── base_api.py # 基础API类
|
|
│ ├── auth_api.py # 认证API
|
|
│ ├── user_api.py # 用户API
|
|
│ ├── role_api.py # 角色API
|
|
│ └── dictionary_api.py # 字典API
|
|
├── tests/
|
|
│ ├── __init__.py
|
|
│ ├── test_auth.py # 认证测试
|
|
│ ├── test_user.py # 用户管理测试
|
|
│ ├── test_role.py # 角色管理测试
|
|
│ ├── test_dictionary.py # 字典管理测试
|
|
│ └── test_oauth2.py # OAuth2测试
|
|
├── utils/
|
|
│ ├── __init__.py
|
|
│ ├── data_generator.py # 测试数据生成器
|
|
│ ├── assertions.py # 断言工具
|
|
│ └── logger.py # 日志工具
|
|
└── reports/ # 测试报告目录
|
|
```
|
|
|
|
## 安装依赖
|
|
|
|
```bash
|
|
# 安装Python依赖
|
|
pip install -r requirements.txt
|
|
|
|
# 安装Playwright浏览器
|
|
playwright install
|
|
```
|
|
|
|
## 运行测试
|
|
|
|
```bash
|
|
# 运行所有测试
|
|
pytest
|
|
|
|
# 运行特定测试文件
|
|
pytest tests/test_auth.py
|
|
|
|
# 运行特定测试用例
|
|
pytest tests/test_auth.py::test_login_success
|
|
|
|
# 生成Allure报告
|
|
pytest --alluredir=allure-results
|
|
allure serve allure-results
|
|
|
|
# 并发运行测试
|
|
pytest -n auto
|
|
```
|
|
|
|
## 配置说明
|
|
|
|
在 `config/settings.py` 中配置:
|
|
- API基础URL
|
|
- 测试数据库连接
|
|
- 测试用户凭证
|
|
- 超时设置
|
|
|
|
## 测试数据管理
|
|
|
|
测试数据自动准备和清理:
|
|
- 每个测试用例独立运行
|
|
- 使用fixture自动创建和清理测试数据
|
|
- 支持数据回滚
|
|
|
|
## 持续集成
|
|
|
|
测试可在CI/CD流程中自动运行:
|
|
- GitHub Actions
|
|
- GitLab CI
|
|
- Jenkins
|