7f683a8aed
- 添加快速开始页面,包含安装、配置、启动指南 - 添加核心功能文档: Agent 系统、工具系统、MCP 集成 - 添加 API 参考文档: REST API、WebSocket、SDK 使用 - 更新侧边栏导航,重新组织文档分类 - 更新 .gitignore 允许 website docs 页面
76 lines
2.0 KiB
Plaintext
76 lines
2.0 KiB
Plaintext
---
|
|
import DocsLayout from '../../../layouts/DocsLayout.astro';
|
|
---
|
|
|
|
<DocsLayout title="测试集成" description="代码修改后自动运行测试并修复">
|
|
<h1>测试集成 (Test Integration)</h1>
|
|
|
|
<p>在代码修改后自动运行测试,并在测试失败时将错误信息反馈给 AI 进行修复,形成"编辑-测试-修复"的闭环。</p>
|
|
|
|
<h2>工作流程</h2>
|
|
<ol>
|
|
<li>AI 编辑代码</li>
|
|
<li>运行相关测试</li>
|
|
<li>如果测试失败,解析错误信息</li>
|
|
<li>将错误反馈给 AI</li>
|
|
<li>AI 修复代码</li>
|
|
<li>重复直到测试通过或达到限制</li>
|
|
</ol>
|
|
|
|
<h2>设计方案</h2>
|
|
|
|
<h3>类型定义</h3>
|
|
<pre><code class="language-typescript">export interface TestResult {
|
|
success: boolean;
|
|
passed: number;
|
|
failed: number;
|
|
skipped: number;
|
|
duration: number;
|
|
failures: TestFailure[];
|
|
output: string;
|
|
}
|
|
|
|
export interface TestFailure {
|
|
testName: string;
|
|
file?: string;
|
|
line?: number;
|
|
message: string;
|
|
stack?: string;
|
|
expected?: string;
|
|
actual?: string;
|
|
}</code></pre>
|
|
|
|
<h3>默认测试配置</h3>
|
|
<pre><code class="language-typescript">export const DEFAULT_TEST_CONFIGS = {
|
|
jest: {
|
|
command: 'npx',
|
|
args: ['jest', '--json', '--testLocationInResults'],
|
|
testFilePatterns: ['**/*.test.ts', '**/*.spec.ts'],
|
|
},
|
|
vitest: {
|
|
command: 'npx',
|
|
args: ['vitest', 'run', '--reporter=json'],
|
|
testFilePatterns: ['**/*.test.ts', '**/*.spec.ts'],
|
|
},
|
|
pytest: {
|
|
command: 'python',
|
|
args: ['-m', 'pytest', '--tb=short', '-v'],
|
|
testFilePatterns: ['**/test_*.py', '**/*_test.py'],
|
|
},
|
|
};</code></pre>
|
|
|
|
<h2>配置示例</h2>
|
|
<pre><code class="language-yaml"># .ai-assistant.yml
|
|
testing:
|
|
enabled: true
|
|
runner: vitest
|
|
autoRun: true
|
|
autoFix: true
|
|
maxFixAttempts: 3
|
|
timeout: 60000
|
|
runRelatedOnly: true</code></pre>
|
|
|
|
<h2>实现状态</h2>
|
|
<p><strong>优先级</strong>: 高 | <strong>状态</strong>: 待实现</p>
|
|
</DocsLayout>
|