- CLI + Web 双平台,基于 LLM 的 TDD+DDD 自动化测试生成 - 集成 unified-test-platform 903 个 D-Cloud 用例 + 13 个 Robogo 场景 - Agent 5 步流水线: 扫描 -> DDD -> LLM 生成测试 - 精确回归 + UI 变更检查 - 可视化 HTML 测试报告 - 暗色/亮色主题切换 - 19 个 API 端点 + 6 个 SPA 页面 - 15/15 项 TDD+DDD 合规
161 lines
4.0 KiB
Markdown
161 lines
4.0 KiB
Markdown
# TestAgent 配置文档
|
||
|
||
## 一、config.yaml
|
||
|
||
```yaml
|
||
agent:
|
||
name: "TestAgent"
|
||
model: "deepseek-v4-pro" # LLM 模型名称
|
||
provider: "openai" # deepseek / openai / anthropic
|
||
base_url: "https://llmgateway.d-robotics.cc/v1"
|
||
temperature: 0.3 # 0.0=确定, 1.0=创意
|
||
max_tokens: 16384
|
||
|
||
git:
|
||
default_branch: "main"
|
||
clone_depth: 50 # git clone 深度
|
||
max_file_size_kb: 500
|
||
|
||
analysis:
|
||
supported_languages: # 支持的语言
|
||
- python
|
||
- typescript
|
||
- javascript
|
||
- go
|
||
- java
|
||
ignore_patterns: # 忽略的文件/目录
|
||
- "**/node_modules/**"
|
||
- "**/__pycache__/**"
|
||
- "**/.git/**"
|
||
- "**/dist/**"
|
||
- "**/build/**"
|
||
- "**/vendor/**"
|
||
- "**/*.min.js"
|
||
- "**/*.bundle.js"
|
||
|
||
test_generation:
|
||
output_dir: "tests" # 测试输出目录
|
||
domain_layer_dir: "tests/domain"
|
||
infrastructure_layer_dir: "tests/infrastructure"
|
||
session_domain_dir: "tests/session"
|
||
smoke_marker: "smoke"
|
||
integration_marker: "integration"
|
||
regression_marker: "regression"
|
||
e2e_marker: "e2e"
|
||
metrics_gate: # 指标门禁
|
||
min_coverage: 60 # 覆盖率 ≥ 60%
|
||
min_pass_rate: 95 # 通过率 ≥ 95%
|
||
|
||
backend:
|
||
host: "0.0.0.0"
|
||
port: 5002
|
||
existing_tests_root: "./tests"
|
||
|
||
plugins:
|
||
enabled:
|
||
- pylint_analyzer # 代码静态分析
|
||
- test_runner # 测试运行 + 门禁
|
||
|
||
logging:
|
||
level: "info"
|
||
format: "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
|
||
```
|
||
|
||
---
|
||
|
||
## 二、.env 环境变量
|
||
|
||
```bash
|
||
# LLM API 配置
|
||
OPENAI_API_KEY=sk-xxx # API Key(必填)
|
||
OPENAI_BASE_URL=https://llmgateway.d-robotics.cc/v1 # API 地址
|
||
|
||
# 测试平台登录凭证
|
||
TEST_USERNAME=admin&tsting # 地瓜机器人平台账号
|
||
TEST_PASSWORD=12345678 # 对应密码
|
||
```
|
||
|
||
**可选环境变量:**
|
||
|
||
| 变量 | 说明 | 默认值 |
|
||
|------|------|--------|
|
||
| `DEEPSEEK_API_KEY` | DeepSeek API Key(兼容模式) | - |
|
||
| `ANTHROPIC_API_KEY` | Anthropic API Key | - |
|
||
| `HEADLESS` | 浏览器无头模式 | `false` |
|
||
|
||
---
|
||
|
||
## 三、Skills 知识库配置
|
||
|
||
知识库位于 `skills/` 目录,每个 Skill 是一个子目录,包含 `SKILL.md` 文件。
|
||
|
||
### 3.1 TDD 方法论 (`skills/tdd-methodology/SKILL.md`)
|
||
- 红-绿-重构循环
|
||
- FIRST 原则(Fast/Independent/Repeatable/Self-Validating/Timely)
|
||
- AAA 模式(Arrange-Act-Assert)
|
||
- 测试命名规范
|
||
- 测试替身(Stub/Mock/Fake/Spy/Dummy)
|
||
|
||
### 3.2 DDD 模式 (`skills/ddd-patterns/SKILL.md`)
|
||
- 限界上下文划分
|
||
- 聚合根/实体/值对象/领域服务/仓储
|
||
- 测试目录结构规范
|
||
- 领域层 vs 基础设施层隔离
|
||
- Session 领域测试
|
||
|
||
### 3.3 测试框架规范 (`skills/test-framework/SKILL.md`)
|
||
- 测试分层(冒烟/集成/系统/回归/指标)
|
||
- 测试标记规范
|
||
- 指标门禁断言
|
||
- CI/CD 流水线链
|
||
- 敏捷迭代规范
|
||
|
||
### 3.4 多语言模式 (`skills/language-patterns/SKILL.md`)
|
||
- Python (pytest + Mock)
|
||
- TypeScript (Jest)
|
||
- Go (testing)
|
||
- 测试数据管理
|
||
|
||
---
|
||
|
||
## 四、插件配置
|
||
|
||
### 4.1 pylint_analyzer
|
||
- 触发时机:`pre_analysis`
|
||
- 功能:行长度检测、TODO/FIXME 标记、print 语句检测、复杂度评估
|
||
|
||
### 4.2 test_runner
|
||
- 触发时机:`post_generation`
|
||
- 功能:运行生成的测试、解析结果、指标门禁检查
|
||
|
||
---
|
||
|
||
## 五、前端配置
|
||
|
||
### 5.1 vite.config.ts
|
||
```typescript
|
||
export default defineConfig({
|
||
plugins: [react(), tailwindcss()],
|
||
server: {
|
||
host: '0.0.0.0',
|
||
port: 5174,
|
||
proxy: {
|
||
'/api': 'http://127.0.0.1:5002',
|
||
'/artifacts': 'http://127.0.0.1:5002',
|
||
},
|
||
},
|
||
})
|
||
```
|
||
|
||
### 5.2 主题配置
|
||
- 暗色/亮色模式切换
|
||
- CSS 自定义属性 14 个主题变量
|
||
- 存储在 `localStorage`,默认跟随系统偏好
|
||
|
||
---
|
||
|
||
## 六、数据清理策略
|
||
|
||
- 任务超过 100 个时自动清除最旧 50 个
|
||
- 清理时同步删除关联的截图和报告文件
|
||
- `platform_db.json` 每次写入时自动清理 |