# TestGPT **Repository Path**: ngcheck/testgpt ## Basic Information - **Project Name**: TestGPT - **Description**: 基于自然语言+AI大模型驱Web UI自动化测试工具 - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://testgpt.itbuilder.cn/ - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 223 - **Created**: 2025-11-25 - **Last Updated**: 2025-11-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # TestGPT 启动指南 ## 1. 前提 - Node.js **>= 18** / npm **>= 8**(`package.json` 里声明) - Python **>= 3.11**,并建议使用 `venv` 创建隔离环境。项目依赖通过 `pyproject.toml` 管理。 - 推荐安装 Chromium(Playwright 使用),`npm run setup` 会自动触发 `playwright install chromium`。 ## 2. 依赖安装 1. Node 依赖: ```bash # Windows(PowerShell) npm run install:all ``` 2. 后端依赖: ```bash # Windows(PowerShell) cd backend python -m venv venv # 如果还没有虚拟环境(是否存在backend/venv目录) .\venv\Scripts\Activate.ps1 python -m pip install --upgrade pip python -m pip install -e . python -m playwright install chromium ``` ## 3. 启动项目 ### 3.1 推荐:前后端一键调试(开发模式) ```bash # Windows(PowerShell) npm run dev ``` - 该脚本通过 `concurrently` 并行启动: - `npm run dev:backend` → `cd backend && python run.py` - `npm run dev:frontend` → `cd frontend && npm run dev` - `backend/run.py` 默认 host `0.0.0.0`、port `8000`、`RELOAD=true` 并打印配置路径(可通过环境变量 `HOST`/`PORT`/`RELOAD` 覆盖)。 - `scripts/dev.sh` 额外提供一个 shell 脚本,先检查依赖、创建虚拟环境再执行 `npm run dev`(主要面向 Linux/macOS)。 ### 3.2 只启动后端 ```bash # Windows(PowerShell) cd backend .\venv\Scripts\Activate.ps1 python run.py ``` - 访问 `http://localhost:8000/docs`(Swagger)或 `/redoc`(Redoc)。 ### 3.3 只启动前端 ```bash # Windows(PowerShell) cd frontend npm run dev ``` - 默认监听 `http://localhost:3000`,通过 Vite 的代理把 `/api` 请求转发到 `http://localhost:8000`。 ## 4. 构建与打包 - `npm run build`(底层执行 `cd frontend && npm run build`)用来打包前端。 - 后端可以使用 `hatch build` 构建 wheel(`pyproject.toml` 已配置),或者直接 `pip install -e backend` 以便本地调试。 ## 5. 其他命令 - `npm run start`:只启动后端(相当于 `cd backend && python run.py`),适合部署环境。 - `npm run build:frontend`:单独打包前端项目。 - `npm run install:all`:纯依赖安装,等价于 `npm install && cd frontend && npm install`。 - `npm run dev:backend` / `npm run dev:frontend`:分别单独启动后端或前端调试环境。 ## 6. 测试 - 后端测试文件集中在 `backend/tests/`(参考 `backend/tests/README.md`)。 运行所有测试: ```bash # Windows(PowerShell) cd backend python -m pytest tests/ ``` 也可以针对单个测试执行(例如 `python -m pytest tests/test_api.py`)。 ## 7. 额外提示 - `backend/run.py` 在启动时会打印配置目录、数据库、截图、历史缓存等路径,便于定位数据文件。 - `frontend` 依赖 `Vite` 和 `Element Plus`,开发时实时热更新,生产构建会输出到 `frontend/dist`。 - 若需要在 Docker 中运行,参考 `docker/docker-compose.yml`、`docker/Dockerfile.backend` 和 `docker/Dockerfile.frontend`。