A/B 测试设计与分析时使用。适用于产品实验、功能验证、转化率优化。融合假设驱动 + 样本量计算 + 置信度判断。
日本語の概要は準備中です。原文の説明を表示しています。
集成测试实现时使用。适用于 API 端到端测试 / 数据库集成 / 第三方 Mock。融合 Testcontainers + Supertest + WireMock。
インストールする前に、エージェントに与えられる指示の中身を確認できます。
1. 用真实依赖(Testcontainers)
不用 H2 / SQLite 替代 PostgreSQL
2. 测试数据隔离
每个测试独立数据,不共享
3. 覆盖主路径 + 关键失败路径
不需要覆盖所有边界(单元测试做)
4. 第三方用 Mock(WireMock)
不依赖真实第三方
// NestJS + Testcontainers
import { PostgreSqlContainer } from '@testcontainers/postgresql';
import { RedisContainer } from '@testcontainers/redis';
describe('OrderController (Integration)', () => {
let app: INestApplication;
let postgres: StartedPostgreSqlContainer;
beforeAll(async () => {
postgres = await new PostgreSqlContainer('postgres:16').start();
const moduleRef = await Test.createTestingModule({
imports: [AppModule],
})
.overrideProvider('DATABASE_URL')
.useValue(postgres.getConnectionUri())
.compile();
app = moduleRef.createNestApplication();
await app.init();
});
afterAll(async () => {
await app.close();
await postgres.stop();
});
it('POST /orders creates order', async () => {
const response = await request(app.getHttpServer())
.post('/api/v1/orders')
.set('Authorization', `Bearer ${validToken}`)
.send({ userId: 1, items: [{ productId: 100, qty: 2 }] })
.expect(201);
expect(response.body.status).toBe('DRAFT');
});
it('GET /orders/:id returns 404 for unknown id', async () => {
await request(app.getHttpServer())
.get('/api/v1/orders/99999')
.set('Authorization', `Bearer ${validToken}`)
.expect(404);
});
});
# FastAPI + Testcontainers
from testcontainers.postgres import PostgresContainer
import pytest
@pytest.fixture(scope='session')
def postgres():
with PostgresContainer('postgres:16') as pg:
yield pg
@pytest.fixture(scope='session')
def client(postgres):
os.environ['DATABASE_URL'] = postgres.get_connection_url()
from main import app
return TestClient(app)
def test_create_order(client, auth_headers):
response = client.post('/api/v1/orders', json={
'user_id': 1,
'items': [{'product_id': 100, 'qty': 2}],
}, headers=auth_headers)
assert response.status_code == 201
assert response.json()['status'] == 'DRAFT'
import { WireMockRestClient } from 'wiremock-rest-client';
const wireMock = new WireMockRestClient('http://localhost:8080');
beforeAll(async () => {
await wireMock.mappings.createMapping({
request: { method: 'POST', url: '/payment/charge' },
response: { status: 200, jsonBody: { success: true, transactionId: 'txn_123' } },
});
});
it('should process payment', async () => {
const result = await paymentService.charge({ amount: 100, currency: 'USD' });
expect(result.transactionId).toBe('txn_123');
});
templates/integration-test-template.md — 集成测试模板□ 用 Testcontainers(真实 DB)
□ 测试数据隔离
□ 第三方用 WireMock
□ 覆盖主路径 + 关键失败
□ 测试独立
□ 清理(afterAll)
□ 不依赖外部网络
上游:
unit-testing → 单元层
下游:
e2e-testing → E2E 层
ci-test-integration → CI 集成
まだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
A/B 测试设计与分析时使用。适用于产品实验、功能验证、转化率优化。融合假设驱动 + 样本量计算 + 置信度判断。
日本語の概要は準備中です。原文の説明を表示しています。
上线前业务方/产品方验收时使用。适用于功能交付确认、UAT、发布会签。融合 BDD Given-When-Then、Specification by Example、ATDD。
日本語の概要は準備中です。原文の説明を表示しています。
设计无障碍可访问的界面时使用。适用于满足 WCAG 标准、键盘导航、屏幕阅读器支持。优先使用 WCAG 2.2 AA 级标准 + 键盘 + 焦点 + 对比度 + ARIA。
日本語の概要は準備中です。原文の説明を表示しています。
实现可访问性(无障碍)时使用。覆盖 WCAG 2.2 AA / ARIA / 键盘导航 / 屏幕阅读器 / 颜色对比 / 焦点管理。融合 React Aria / Radix UI / Headless UI 实践 + axe-core 自动化测试。
日本語の概要は準備中です。原文の説明を表示しています。
AI 模型部署时使用。适用于推理服务 / GPU / TensorRT / 监控 / 扩缩容。
日本語の概要は準備中です。原文の説明を表示しています。
数据分析报告输出时使用。适用于业务分析报告、周报、专项分析、决策支持。融合洞察 + 建议 + 行动项。
日本語の概要は準備中です。原文の説明を表示しています。