AgentSkillsCN

testing-strategies

此技能适用于测试覆盖率评估、测试金字塔模型、单元测试/集成测试/E2E 测试的设计,以及 TDD、BDD 测试方法、Mock 模拟策略、测试双胞胎技术与测试架构的构建。

SKILL.md
--- frontmatter
name: testing-strategies
description: This skill should be used for test coverage, test pyramid, unit/integration/E2E test design, TDD, BDD, mocking strategies, test doubles, test architecture
whenToUse: Designing tests, coverage strategy, test pyramid, TDD, BDD, mocking, test doubles, test organization, E2E testing, integration testing strategy
whenNotToUse: Simple test additions, established patterns, single test file edits
seeAlso:
  - skill: architecture-patterns
    when: test architecture decisions
  - skill: react-patterns
    when: React component testing
  - skill: python-patterns
    when: pytest patterns
  - skill: go-patterns
    when: Go table-driven tests
  - skill: superpowers:test-driven-development
    when: writing tests first, rigorous TDD discipline

Testing Strategies

Comprehensive test design for deployment readiness.

Test Pyramid

code
    /  E2E  \       Few, slow, expensive
   /  Integ  \      Some, medium
  /   Unit    \     Many, fast, cheap

Coverage Guidelines

LevelCoverageFocus
Unit80%+Business logic
IntegrationKey pathsAPIs, DB
E2ECritical flowsUser journeys

Unit Test Patterns

  • Test one thing per test
  • Clear arrange/act/assert
  • Mock external dependencies
  • Fast execution (<1s each)

Integration Test Patterns

  • Test real dependencies
  • Use test databases
  • Clean up after tests
  • Cover API contracts

E2E Test Patterns

  • Critical user journeys only
  • Stable selectors
  • Retry flaky network calls
  • Parallel where possible