# test_platform **Repository Path**: wind_juvenile/test_platform ## Basic Information - **Project Name**: test_platform - **Description**: 测试综合平台 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-27 - **Last Updated**: 2026-01-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Test Platform - 测试管理平台 一个现代化的测试管理平台,提供完整的测试用例管理、测试计划执行、缺陷跟踪和自动化测试功能。 ## 项目概述 Test Platform 是一个全栈测试管理解决方案,包含: - **后端**: Python FastAPI + SQLAlchemy + SQLite - **前端**: Vue 3 + TypeScript + Element Plus - **数据库**: SQLite (支持迁移到其他数据库) ## 主要功能 ### 1. 测试管理 - 测试用例管理(创建、编辑、版本控制) - 测试计划制定与执行 - 测试运行记录与结果跟踪 - 模块化组织测试用例 ### 2. 缺陷跟踪 - 缺陷创建与分配 - 缺陷状态流转 - 缺陷评论与附件 - 缺陷历史记录 ### 3. 自动化测试 - 自动化脚本管理 - CI/CD 集成 - 自动化执行记录 - 测试结果分析 ### 4. 项目管理 - 多项目管理 - 团队成员管理 - 权限控制(管理员、测试人员、开发人员) - 项目统计与报告 ### 5. 其他功能 - 实时通知系统 - 数据导入导出 - 审计日志 - 仪表板与报表 ## 技术栈 ### 后端 - **Python 3.13+** - **FastAPI** - 高性能Web框架 - **SQLAlchemy** - ORM - **Alembic** - 数据库迁移 - **Pydantic** - 数据验证 - **JWT** - 身份验证 - **SQLite** - 数据库(默认) ### 前端 - **Vue 3** - 前端框架 - **TypeScript** - 类型安全 - **Element Plus** - UI组件库 - **Pinia** - 状态管理 - **Vue Router** - 路由管理 - **Axios** - HTTP客户端 - **Vite** - 构建工具 ## 快速开始 ### 1. 克隆项目 ```bash git clone https://gitee.com/wind_juvenile/test_platform.git cd test_platform ``` ### 2. 后端设置 #### 安装Python依赖 ```bash cd backend pip install fastapi sqlalchemy pydantic-settings python-jose passlib bcrypt alembic uvicorn ``` #### 初始化数据库 ```bash python init_db.py ``` #### 启动后端服务器 ```bash uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 ``` 后端将在 http://localhost:8000 运行,API文档在 http://localhost:8000/docs ### 3. 前端设置 #### 安装Node.js依赖 ```bash cd frontend npm install npm install @element-plus/icons-vue ``` #### 启动开发服务器 ```bash npm run dev ``` 前端将在 http://localhost:5173 运行 ### 4. 访问平台 1. 打开浏览器访问 http://localhost:5173 2. 使用默认账号登录: - 用户名: `admin` - 密码: `admin123` ## 项目结构 ``` test_platform/ ├── backend/ # 后端代码 │ ├── app/ # 应用主目录 │ │ ├── api/routes/ # API路由 │ │ ├── core/ # 核心配置 │ │ ├── db/ # 数据库相关 │ │ │ ├── models/ # 数据模型 │ │ │ ├── schemas/ # Pydantic模式 │ │ │ └── migrations/ # 数据库迁移 │ │ ├── services/ # 业务逻辑 │ │ └── utils/ # 工具函数 │ ├── uploads/ # 文件上传目录 │ └── *.py # 各种工具脚本 ├── frontend/ # 前端代码 │ ├── src/ # 源代码 │ │ ├── api/ # API调用 │ │ ├── components/ # Vue组件 │ │ ├── pages/ # 页面组件 │ │ ├── router/ # 路由配置 │ │ ├── store/ # 状态管理 │ │ └── utils/ # 工具函数 │ ├── public/ # 静态资源 │ └── *.json # 配置文件 └── README.md # 本文档 ``` ## API接口 ### 认证相关 - `POST /auth/login` - 用户登录 - `POST /auth/register` - 用户注册 - `POST /auth/refresh` - 刷新令牌 ### 项目管理 - `GET /projects` - 获取项目列表 - `POST /projects` - 创建项目 - `GET /projects/{project_id}` - 获取项目详情 - `PUT /projects/{project_id}` - 更新项目 - `DELETE /projects/{project_id}` - 删除项目 ### 测试用例管理 - `GET /projects/{project_id}/cases` - 获取测试用例列表 - `POST /projects/{project_id}/cases` - 创建测试用例 - `GET /projects/{project_id}/cases/{case_id}` - 获取测试用例详情 - `PUT /projects/{project_id}/cases/{case_id}` - 更新测试用例 - `DELETE /projects/{project_id}/cases/{case_id}` - 删除测试用例 ### 测试计划管理 - `GET /projects/{project_id}/plans` - 获取测试计划列表 - `POST /projects/{project_id}/plans` - 创建测试计划 - `GET /projects/{project_id}/plans/{plan_id}` - 获取测试计划详情 ### 测试执行管理 - `GET /runs` - 获取测试运行列表 - `POST /runs` - 创建测试运行 - `GET /runs/{run_id}` - 获取测试运行详情 - `PUT /runs/{run_id}` - 更新测试运行状态 ### 缺陷管理 - `GET /projects/{project_id}/defects` - 获取缺陷列表 - `POST /projects/{project_id}/defects` - 创建缺陷 - `GET /projects/{project_id}/defects/{defect_id}` - 获取缺陷详情 - `PUT /projects/{project_id}/defects/{defect_id}` - 更新缺陷 ## 数据库设计 ### 主要数据表 1. **users** - 用户信息 2. **projects** - 项目信息 3. **project_members** - 项目成员 4. **modules** - 项目模块 5. **test_cases** - 测试用例 6. **test_case_versions** - 测试用例版本 7. **test_plans** - 测试计划 8. **test_plan_items** - 测试计划项 9. **test_runs** - 测试运行 10. **test_run_items** - 测试运行项 11. **defects** - 缺陷 12. **defect_comments** - 缺陷评论 13. **defect_attachments** - 缺陷附件 14. **automation_scripts** - 自动化脚本 15. **automation_executions** - 自动化执行记录 16. **notifications** - 通知 17. **audit_logs** - 审计日志 ## 开发指南 ### 后端开发 #### 创建新的API路由 1. 在 `backend/app/api/routes/` 创建新的路由文件 2. 在 `backend/app/main.py` 中注册路由 3. 创建对应的数据模型和模式 #### 数据库迁移 ```bash cd backend alembic revision --autogenerate -m "描述" alembic upgrade head ``` #### 运行测试 ```bash python test_automation.py python test_progress_api.py ``` ### 前端开发 #### 创建新页面 1. 在 `frontend/src/pages/` 创建Vue组件 2. 在 `frontend/src/router/index.ts` 中添加路由 3. 在 `frontend/src/api/` 创建对应的API调用 #### 组件开发 - 使用Element Plus组件库 - 遵循Vue 3 Composition API - 使用TypeScript确保类型安全 ## 配置说明 ### 后端配置 配置文件: `backend/app/core/config.py` ```python class Settings(BaseSettings): app_name: str = "Test Platform" secret_key: str = "CHANGE_ME" # 生产环境需要修改 algorithm: str = "HS256" access_token_expires_minutes: int = 60 database_url: str = "sqlite:///test_platform.db" ``` ### 前端配置 - 环境变量: `frontend/.env` - API基础URL: `frontend/src/api/http.ts` - 路由配置: `frontend/src/router/index.ts` ## 部署指南 ### 生产环境部署 #### 后端部署 1. 修改配置文件中的密钥和数据库连接 2. 使用生产级服务器(如Gunicorn + Uvicorn) 3. 配置反向代理(Nginx/Apache) 4. 设置SSL证书 #### 前端部署 1. 构建生产版本 ```bash cd frontend npm run build ``` 2. 部署到Web服务器(Nginx/Apache) 3. 配置API代理 ### Docker部署(示例) ```dockerfile # 后端Dockerfile FROM python:3.13-slim WORKDIR /app COPY backend/requirements.txt . RUN pip install -r requirements.txt COPY backend/ . CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] ``` ## 故障排除 ### 常见问题 #### 1. 数据库连接失败 - 检查数据库文件权限 - 确认SQLite文件路径正确 - 运行 `python backend/init_db.py` 重新初始化 #### 2. 前端图标不显示 ```bash cd frontend npm install @element-plus/icons-vue npm run dev ``` #### 3. API调用失败 - 检查后端服务是否运行 - 确认CORS配置正确 - 查看浏览器控制台错误信息 #### 4. 依赖安装问题 - 使用虚拟环境隔离依赖 - 确保Python和Node.js版本符合要求 - 清除缓存重新安装 ### 调试工具 - 后端: FastAPI自动生成的 `/docs` 和 `/redoc` - 前端: Vue DevTools浏览器扩展 - 数据库: SQLite浏览器工具 ## 贡献指南 1. Fork项目 2. 创建功能分支 (`git checkout -b feature/AmazingFeature`) 3. 提交更改 (`git commit -m 'Add some AmazingFeature'`) 4. 推送到分支 (`git push origin feature/AmazingFeature`) 5. 创建Pull Request ## 许可证 本项目采用MIT许可证 - 查看LICENSE文件了解详情 ## 联系方式 - 项目仓库: https://gitee.com/wind_juvenile/test_platform - 问题反馈: 请使用Git Issues ## 更新日志 ### v0.1.0 (当前版本) - 基础测试管理功能 - 缺陷跟踪系统 - 自动化测试集成 - 用户权限管理 - 实时通知系统 --- **注意**: 这是一个开发中的项目,功能正在不断完善中。生产环境使用前请进行充分测试。