# ServicePilot 测试脚本目录说明 本目录按课程作业要求拆分为四类测试脚本: ```text tests/ ├─ unit_tests/ # 单元测试脚本 ├─ api_tests/ # 接口测试脚本 ├─ auto_tests/ # 自动化测试脚本 └─ performance_tests/ # Locust 性能测试脚本 ``` ## 1. 单元测试 位置:`tests/unit_tests` 覆盖内容: - 工单状态流转规则 - 用户权限隔离规则 - SLA 截止时间、预警、超时判断 - 附件类型和大小校验 运行命令: ```powershell cd E:\软测\ServicePilot\tests\unit_tests powershell -ExecutionPolicy Bypass -File .\run_unit_tests.ps1 ``` ## 2. 接口测试 位置:`tests/api_tests` 覆盖内容: - `/api/health` - `/api/config/parse` - 404 错误响应 - Parse 配置敏感字段不暴露 运行命令: ```powershell cd E:\软测\ServicePilot\tests\api_tests powershell -ExecutionPolicy Bypass -File .\run_api_tests.ps1 ``` ## 3. 自动化测试 位置:`tests/auto_tests` 覆盖内容: - dashboard - tickets - sla - knowledge - files - reviews - test-plan 运行前先启动前端或静态预览: ```powershell cd E:\软测\ServicePilot\project\frontend npm.cmd run build D:\nodejs\node.exe scripts\static-preview.cjs ``` 再执行: ```powershell cd E:\软测\ServicePilot\tests\auto_tests powershell -ExecutionPolicy Bypass -File .\run_auto_tests.ps1 ``` ## 4. 性能测试 位置:`tests/performance_tests` 覆盖内容: - 后端健康检查接口 - Parse 配置接口 - 404 错误接口 - 前端关键页面访问 需要安装 Locust: ```powershell pip install locust ``` 运行后端接口性能测试: ```powershell cd E:\软测\ServicePilot\tests\performance_tests powershell -ExecutionPolicy Bypass -File .\run_backend_performance.ps1 ``` 运行前端页面性能测试: ```powershell cd E:\软测\ServicePilot\tests\performance_tests powershell -ExecutionPolicy Bypass -File .\run_frontend_performance.ps1 ```