AgentSkillsCN

Test Strategy Design

测试策略设计

SKILL.md

Test Strategy Design

Purpose

Design a comprehensive testing strategy for a project or module, selecting the appropriate mix of test types, tools, and coverage targets based on the system's risk profile, architecture, and team capabilities.

When to Use

  • Starting a new project and establishing testing practices
  • Reviewing and improving an existing test strategy
  • Adding a new module or service that needs a testing plan
  • Preparing for a production launch or compliance audit
  • After an incident that revealed testing gaps

Steps

Step 1: Understand the System

Gather context:

  • Architecture: Monolith, microservices, serverless, frontend SPA, etc.
  • Languages: Go, Python, TypeScript, etc.
  • Critical paths: What operations must never fail? (payments, auth, data integrity)
  • Risk profile: Financial, healthcare, consumer, internal tool?
  • Team size and experience: How much testing infrastructure can they maintain?
  • Existing tests: What exists? What's the current coverage? Any known gaps?

Step 2: Map Test Types to System Layers

System LayerPrimary Test TypesSecondary Test Types
Domain/business logicUnit, property-basedMutation
API handlersIntegration, contractFuzz
Data accessIntegration (with real DB)Property-based
External integrationsContract, integrationE2E
Frontend componentsComponent, snapshotVisual regression, a11y
User journeysE2EBDD/acceptance
InfrastructureSmokeChaos
SecuritySAST/DAST, fuzzPenetration

Step 3: Define the Test Pyramid

Determine the distribution based on the architecture:

Backend-Heavy System:

code
Unit (60%) > Integration (25%) > E2E (10%) > Smoke (5%)
Property-based and fuzz tests supplement unit tests on critical paths.

Frontend-Heavy System:

code
Component (50%) > Integration (20%) > Visual (10%) > E2E (10%) > A11y (10%)

Full-Stack Application:

code
Unit/Component (50%) > Integration (25%) > E2E (10%) > Visual/A11y (10%) > Smoke (5%)

Step 4: Select Tools per Test Type

For each test type in the strategy, select tools based on the language and ecosystem:

Go:

Test TypeTool
Unittesting + testify
Property-basedpgregory.net/rapid
FuzzNative testing.F
Integrationtestcontainers-go
E2Enet/http/httptest
BDDgodog
Mutationgo-mutesting

Python:

Test TypeTool
Unitpytest
Property-basedhypothesis
Fuzzatheris
Integrationtestcontainers
BDDpytest-bdd
Mutationmutmut

TypeScript:

Test TypeTool
Unitvitest or jest
Property-basedfast-check
Component@testing-library/react
VisualPlaywright screenshots or Chromatic
A11yjest-axe + @axe-core/playwright
E2EPlaywright
SnapshotVitest/Jest built-in
BDDcucumber-js + playwright-bdd
MutationStryker

Step 5: Define Coverage Targets

Set realistic, risk-adjusted targets:

Module Risk LevelLine CoverageBranch CoverageMutation Score
Critical (financial, auth)90%+85%+85%+
High (core business logic)85%+80%+75%+
Medium (API, services)80%+75%+70%+
Low (utilities, config)70%+65%+60%+

Step 6: Design CI Pipeline Integration

Map test types to pipeline stages:

yaml
on_every_commit:
  - lint
  - unit tests
  - component tests
  - accessibility tests (axe)

on_pull_request:
  - all of the above
  - integration tests
  - snapshot tests
  - visual regression tests
  - mutation tests (incremental, changed files only)

on_merge_to_main:
  - all of the above
  - E2E tests
  - smoke tests
  - full mutation testing

nightly:
  - fuzz testing (extended duration)
  - property-based tests (extended examples)
  - performance/load tests
  - security scanning (SAST/DAST)

Step 7: Establish Test Quality Standards

Define standards for test code itself:

  • Naming: TestFunctionName_Scenario_ExpectedBehavior (Go), it('does X when Y') (JS)
  • Structure: Arrange-Act-Assert (unit), Given-When-Then (BDD)
  • Independence: Tests must not depend on execution order
  • Speed: Unit < 100ms, integration < 5s, E2E < 30s per test
  • Determinism: No flaky tests allowed in main branch

Step 8: Plan for Maintenance

  • Flaky test quarantine: Move flaky tests to a separate suite, fix within 1 sprint
  • Test debt tracking: Track untested modules and weak test areas
  • Coverage trending: Monitor coverage trends over time (never let it decrease)
  • Regular strategy reviews: Quarterly review of test strategy effectiveness

Output Format

Produce:

  1. Test strategy document mapping test types to system layers
  2. Tool selection matrix with justifications
  3. Coverage targets per module/risk level
  4. CI pipeline configuration showing when each test type runs
  5. Test quality standards and naming conventions
  6. Maintenance plan for ongoing test health