Files
novalon-manage-system/e2e_tests
张翔 9f8bf041c3 feat: 更新端口配置并添加监控支持
fix: 修复测试配置和依赖检查

perf: 优化雪花算法性能

refactor: 清理冗余代码和未使用的导入

style: 统一代码格式和注释

test: 添加单元测试和集成测试

ci: 更新CI配置和构建脚本

chore: 更新依赖和配置文件
2026-03-13 08:50:19 +08:00
..

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/                 # 测试报告目录

安装依赖

# 安装Python依赖
pip install -r requirements.txt

# 安装Playwright浏览器
playwright install

运行测试

# 运行所有测试
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