# ServicePilot 综合测试脚本目录说明 本目录按课程作业和历史实训提交方式拆分为四类测试单元。每个测试单元均包含测试说明、脚本入口和结果证据,便于分别提交、分别说明测试结果。 ```text tests/ ├─ unit_tests/ # 单元测试脚本 ├─ api_tests/ # 接口测试脚本 ├─ auto_tests/ # 自动化测试脚本与页面截图 └─ performance_tests/ # Locust 性能测试脚本 ``` 提交结构说明见:`tests/提交结构说明.md` ## 1. 单元测试 位置:`tests/unit_tests` 覆盖内容: - 工单状态流转规则 - 用户权限隔离规则 - SLA 截止时间、预警、超时判断 - 附件类型和大小校验 运行命令: ```powershell cd E:\软测\ServicePilot\tests\unit_tests powershell -ExecutionPolicy Bypass -File .\run_unit_tests.ps1 ``` 结果输出: ```text tests/unit_tests/reports/unit_test_log.txt tests/unit_tests/reports/unit_test_summary.txt ``` ## 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 ``` 结果输出: ```text tests/api_tests/reports/api_test_log.txt tests/api_tests/reports/api_test_summary.txt ``` ## 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 ``` 结果输出: ```text tests/auto_tests/reports/auto_test_log.txt tests/auto_tests/reports/auto_test_summary.txt tests/auto_tests/artifacts/*.png tests/auto_tests/artifacts/auto-test-result.json ``` ## 4. 性能测试 位置:`tests/performance_tests` 覆盖内容: - 后端健康检查接口 - Parse 配置接口 - 404 错误接口 - 前端关键页面访问 需要安装 Locust: ```powershell cd E:\软测\ServicePilot\tests\performance_tests pip install -r requirements.txt ``` 运行后端接口性能测试: ```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 ``` 结果输出: ```text tests/performance_tests/性能测试报告.md tests/performance_tests/reports/backend-performance-report.html tests/performance_tests/reports/backend-performance_*.csv tests/performance_tests/reports/frontend-performance-report.html tests/performance_tests/reports/frontend-performance_*.csv ``` 当前环境如未安装 Locust,脚本会生成 `reports/*_performance_pending.txt`,不伪造性能结果。