testing-integration

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Integration Testing

集成测试

Test interactions between multiple components, modules, or services.
测试多个组件、模块或服务之间的交互。

When to use me

适用场景

Use this skill when:
  • Components have been unit tested and need to work together
  • Testing API contracts between services
  • Verifying database interactions work correctly
  • Checking third-party service integrations
  • Ensuring microservices communicate properly
  • Validating data flows through the system
在以下场景使用本技能:
  • 组件已完成单元测试,需要验证协同工作情况
  • 测试服务之间的API契约
  • 验证数据库交互是否正常工作
  • 检查第三方服务集成
  • 确保微服务通信正常
  • 验证数据在系统中的流转

What I do

功能说明

  • Identify integration points between components
  • Set up test environments with real or test databases
  • Configure service connections and API endpoints
  • Test data flow between integrated components
  • Verify error handling across component boundaries
  • Check contract compliance between services
  • Validate end-to-end workflows without UI
  • 识别组件之间的集成点
  • 使用真实或测试数据库搭建测试环境
  • 配置服务连接和API端点
  • 测试集成组件之间的数据流转
  • 验证跨组件边界的错误处理
  • 检查服务之间的契约合规性
  • 无需UI即可验证端到端工作流

Examples

示例

bash
undefined
bash
undefined

Run integration tests

Run integration tests

npm run test:integration # Node.js integration tests pytest tests/integration/ # Python integration tests go test -tags=integration # Go integration tests
npm run test:integration # Node.js integration tests pytest tests/integration/ # Python integration tests go test -tags=integration # Go integration tests

Test specific integrations

Test specific integrations

npm run test:integration -- --grep "database" pytest tests/integration/test_api_client.py
npm run test:integration -- --grep "database" pytest tests/integration/test_api_client.py

Run with test containers for external services

Run with test containers for external services

docker-compose -f docker-compose.test.yml up --abort-on-container-exit
undefined
docker-compose -f docker-compose.test.yml up --abort-on-container-exit
undefined

Output format

输出格式

Integration Test Results:
──────────────────────────────
✅ API Service ↔ Database
  ✓ User data persists correctly
  ✓ Transaction rollback on failure

❌ Payment Service ↔ Banking API
  ✗ Authentication token refresh fails
  ✗ Currency conversion rate mismatch

⚠️ Email Service ↔ Queue
  ⚠️ Message retention period too short

Summary: 8 passed, 2 failed, 1 warning
Integration Test Results:
──────────────────────────────
✅ API Service ↔ Database
  ✓ User data persists correctly
  ✓ Transaction rollback on failure

❌ Payment Service ↔ Banking API
  ✗ Authentication token refresh fails
  ✗ Currency conversion rate mismatch

⚠️ Email Service ↔ Queue
  ⚠️ Message retention period too short

Summary: 8 passed, 2 failed, 1 warning

Notes

注意事项

  • Integration tests are slower than unit tests
  • Use test databases or in-memory databases
  • Mock only external third-party services
  • Test happy paths and error scenarios
  • Clean up test data between tests
  • Consider using test containers for external dependencies
  • Focus on contract testing for microservices
  • 集成测试比单元测试慢
  • 使用测试数据库或内存数据库
  • 仅模拟外部第三方服务
  • 测试正常流程和错误场景
  • 在测试之间清理测试数据
  • 考虑为外部依赖使用测试容器
  • 微服务重点关注契约测试