Files
ai-terminal-assistant/packages/website/src/pages/docs/features/testing.astro
T
kurihada 7f683a8aed docs(website): 完善文档页面结构
- 添加快速开始页面,包含安装、配置、启动指南
- 添加核心功能文档: Agent 系统、工具系统、MCP 集成
- 添加 API 参考文档: REST API、WebSocket、SDK 使用
- 更新侧边栏导航,重新组织文档分类
- 更新 .gitignore 允许 website docs 页面
2025-12-18 00:09:30 +08:00

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 &#123;
success: boolean;
passed: number;
failed: number;
skipped: number;
duration: number;
failures: TestFailure[];
output: string;
&#125;
export interface TestFailure &#123;
testName: string;
file?: string;
line?: number;
message: string;
stack?: string;
expected?: string;
actual?: string;
&#125;</code></pre>
<h3>默认测试配置</h3>
<pre><code class="language-typescript">export const DEFAULT_TEST_CONFIGS = &#123;
jest: &#123;
command: 'npx',
args: ['jest', '--json', '--testLocationInResults'],
testFilePatterns: ['**/*.test.ts', '**/*.spec.ts'],
&#125;,
vitest: &#123;
command: 'npx',
args: ['vitest', 'run', '--reporter=json'],
testFilePatterns: ['**/*.test.ts', '**/*.spec.ts'],
&#125;,
pytest: &#123;
command: 'python',
args: ['-m', 'pytest', '--tb=short', '-v'],
testFilePatterns: ['**/test_*.py', '**/*_test.py'],
&#125;,
&#125;;</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>