agentleFS
camilooscargbaptistacamilooscargbaptista/cto-toolkit/testing-strategy/SKILL.md

testing-strategy

Skill9 starsChanged 8 months agoMITView on GitHub

**Testing Strategy (TDD, BDD, QA)**: Expert guide for test-driven development, behavior-driven development, unit testing, integration testing, E2E testing, and QA processes. Use whenever the user wants to write tests, set up a testing strategy, implement TDD/BDD, create test plans, review test coverage, or mentions 'test', 'TDD', 'BDD', 'unit test', 'integration test', 'e2e', 'end-to-end', 'jest', 'mocha', 'cypress', 'playwright', 'JUnit', 'testing-library', 'mock', 'stub', 'coverage', 'QA', 'quality assurance', 'test plan', or asks 'how should I test this' or 'what tests do I need'.

59 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use api-contract-design, deploy-checklist and 7 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MohOneXSkill

    api-contract-design

    Designs and reviews API contracts (REST, RPC, GraphQL, library interfaces) for evolvability, backward compatibility, and failure semantics. Use when defining new endpoints/interfaces, versioning an API, reviewing a schema, or deciding how breaking changes propagate to clients.

    Also in 3 projects that use this

  • AnthropicSkill

    deploy-checklist

    Pre-deployment verification checklist. Use when about to ship a release, deploying a change with database migrations or feature flags, verifying CI status and approvals before going to production, or documenting rollback triggers ahead of time.

    Also in 4 projects that use this

  • xenitV1Skill

    react-patterns

    Modern React patterns and principles. Hooks, composition, performance, TypeScript best practices.

    Also in 4 projects that use this

  • AnthropicSkill

    tech-debt

    Identify, categorize, and prioritize technical debt. Trigger with "tech debt", "technical debt audit", "what should we refactor", "code health", or when the user asks about code quality, refactoring priorities, or maintenance backlog.

    Also in 4 projects that use this

  • MicrosoftSkill

    error-handling

    统一错误处理系统。在添加 API 端点、修改错误处理、添加前端 API 调用、编写错误相关测试时使用。

    Also in 5 projects that use this

  • MicrosoftSkill

    api-design

    Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.

    Also in 10 projects that use this

  • +2 more from anthropics

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 47 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Integration tests: Test API endpoints, database queries, service interactions.

    line 110
  2. Distinctive:

    E2E tests: Test critical user journeys only (registration, checkout, payment).

    line 111
  3. Distinctive:

    Avoid anti-patterns: No sleep-based waits, no test data assumptions, clean up after tests.

    line 112

“Common” is measured: kept by at least 6 in 10 of the 47 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Testing Strategy — TDD, BDD & QA

You are a senior QA engineer and testing advocate. Help the user write better tests, implement TDD/BDD workflows, and build a testing culture that catches bugs early without slowing down development.

Testing Pyramid

        ╱ ╲
       ╱ E2E ╲           Few, slow, expensive — critical user paths only
      ╱───────╲
     ╱Integration╲       Moderate — API, DB, service interactions
    ╱─────────────╲
   ╱   Unit Tests   ╲    Many, fast, cheap — business logic, pure functions
  ╱───────────────────╲
LevelSpeedCountWhat to Test
Unit<10msHundredsBusiness logic, pure functions, domain entities
Integration<5sDozensAPI endpoints, DB queries, service interactions
E2E<30sHandfulCritical user journeys, cross-system flows

Test-Driven Development (TDD)

The Red-Green-Refactor Cycle

1. RED    → Write a failing test for the behavior you want
2. GREEN  → Write the minimum code to make it pass
3. REFACTOR → Clean up without changing behavior (tests still pass)
4. Repeat

Why it works: Tests define the contract before implementation, catch bugs early, and prevent over-engineering. Tests become documentation.

When TDD Works Best

  • Domain logic with clear inputs/outputs
  • Bug fixes (write the failing test first, then fix)
  • API contracts (test the interface before implementing)
  • Algorithms and calculations

When TDD is Less Useful

  • Exploratory coding / prototyping
  • UI layout (hard to test visually)
  • Infrastructure glue code
  • One-off scripts

Behavior-Driven Development (BDD)

BDD bridges business requirements and technical tests using natural language. Gherkin syntax lets non-technical stakeholders read and approve tests.

Key benefit: Reduces miscommunication. Everyone agrees on requirements before coding.

For detailed BDD/Gherkin examples with Scenario Outlines and TypeScript step definitions, read references/bdd-examples.md

Unit Testing Best Practices

The AAA Pattern

Arrange (setup) → Act (execute) → Assert (verify). Keep tests simple and focused on one behavior.

Test Naming Convention

Pattern: should [expected behavior] when [condition]
it('should return empty array when no users match the filter')
it('should throw InsufficientFundsError when balance is below transfer amount')

FIRST Properties

  • Fast — Runs in milliseconds, no I/O
  • Isolated — No dependency on other tests or external state
  • Repeatable — Same result every time
  • Self-validating — Pass/fail, no manual checking
  • Timely — Written close to the code it tests

Mocking Strategy

Mock: External services, APIs, databases
Stub: Simple return values for dependencies
Fake: In-memory implementations (fake repository)
Spy: Verify interactions without changing behavior

Rule: Don't mock what you don't own.
Instead, wrap external dependencies in your own interface and mock that.

Integration & E2E Testing

For detailed API test examples (supertest), database test best practices, and E2E testing patterns with Playwright/Cypress, read references/integration-test-patterns.md

Key Principles

  • Integration tests: Test API endpoints, database queries, service interactions. Use real test database (not mocked).
  • E2E tests: Test critical user journeys only (registration, checkout, payment). Avoid testing everything E2E.
  • Avoid anti-patterns: No sleep-based waits, no test data assumptions, clean up after tests.

Test Coverage Guidelines

AreaTargetWhy
Domain logic90%+Core business rules must be correct
Application services80%+Use cases should be well-tested
API endpoints70%+Integration tests for contracts
Infrastructure50%+Focus on query correctness
UI components60%+Widget/component tests for logic

Coverage is a useful metric but not a goal. 100% coverage with bad tests is worse than 70% coverage with meaningful tests. Test behavior, not implementation details.

Atomic Testing (Micro-Commits)

Each test should verify one behavior. Each commit should be a single, working change.

✅ "test: add unit test for volume discount calculation"
✅ "feat: implement volume discount for orders >$100"
✅ "refactor: extract discount rules into strategy pattern"

❌ "feat: add discount system with tests and refactoring"

QA Test Planning

For the full test plan template with scope, scenarios (happy path, edge cases, error cases, performance, security), environment, and exit criteria, read references/test-plan-template.md

A good test plan ensures comprehensive coverage and clear pass/fail criteria before testing begins.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.