AgentSkillsCN

Testing Strategies Skill

在不过度测试的前提下,通过系统化测试提升信心。

SKILL.md
--- frontmatter
name: "Testing Strategies Skill"
description: "Systematic testing for confidence without over-testing."
applyTo: "**/*test*,**/*spec*,**/*.test.*,**/*.spec.*"

Testing Strategies Skill

Systematic testing for confidence without over-testing.

Testing Pyramid

LevelVolumeSpeedPurpose
UnitManyFastIndividual functions
IntegrationSomeMediumComponent boundaries
E2EFewSlowUser journeys

Anti-pattern: Inverted pyramid (too many E2E, few unit).

Unit Test Pattern (AAA)

typescript
test('should [behavior] when [condition]', () => {
    // Arrange - setup
    // Act - execute
    // Assert - verify
});

What to Mock

MockDon't Mock
External servicesYour own code
Time/randomnessPure functions
Network callsBusiness logic

Coverage Philosophy

RangeInterpretation
50-70%Reasonable
70-85%Good, diminishing returns
85%+Often wasteful

Focus: Coverage of changed code.

Don't Test

  • Third-party internals
  • Framework behavior
  • Private implementation
  • Trivial getters/setters

TDD Cycle

Red → Green → Refactor

Synapses

See synapses.json for connections.