agentleFS
sagullapallisagullapalli/claude-code-setup/.claude/skills/testing-strategy/SKILL.md

testing-strategy

Skill4 starsChanged 10 months agoMITView on GitHub

Comprehensive testing patterns - unit, integration, E2E, accessibility, security. Use when writing tests, setting up test infrastructure, or TDD.

  • Deletes or force-pushes

37 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use react-patterns, api-design and 10 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.
  • benshapyroSkill

    react-patterns

    Modern React patterns for TypeScript applications including hooks, state management, and component composition. Use when building React components, managing state, or implementing React best practices.

    Also in 4 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

  • OpenAISkill

    observability

    Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.

    Also in 5 projects that use this

  • Microsoft AzureSkill

    git-workflow

    Squad branching model: dev-first workflow with insiders preview channel

    Also in 6 projects that use this

  • MicrosoftSkill

    error-handling

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

    Also in 3 projects that use this

  • CloudAI-XSkill

    database-design

    Designs database schemas, indexing strategies, query optimization, and migration patterns for SQL and NoSQL databases. Use when designing tables, optimizing queries, fixing N+1 problems, planning migrations, or when asked about database performance, normalization, ORMs, or data modeling.

    Also in 3 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. 0 are common, 8 are distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 33 edited versions we read keep these.

  • 8

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Fix: Test behavior, not code structure.

    line 137
  2. Distinctive:

    Fix: Use semantic assertions. See 08-ai-llm-testing.md

    line 145
  3. Distinctive:

    Fix: Use fixtures, clean up after tests.

    line 149
  4. Distinctive:

    Fix: Follow testing pyramid. See 01-testing-philosophy.md

    line 157
  5. Very specific:

    Use keyword presence: assert "Paris" in response

    line 196
  6. Very specific:

    Use JSON mode: response_format="json" for structure

    line 197
  7. Very specific:

    Use length bounds: assert 50 < len(response) < 200

    line 198
  8. Very specific:

    Test SQL injection payloads: "'.

    line 205
  9. Very specific:

    Test SSRF: Block private IPs (127.0.0.1, 169.254.169.254)

    line 207
  10. Distinctive:

    Fix immediately: - don't accumulate flaky tests!

    line 213
  11. Very specific:

    Never use sleep() - use explicit waits

    line 214
  12. Distinctive:

    Never share state - use fixtures for isolation

    line 215
  13. Distinctive:

    Never depend on test order - each test independent

    line 216
  14. Distinctive:

    Introduction: When to use this testing approach

    line 245
  15. Very specific:

    Navigation: Always load SKILL.md first for quick reference, then specific module for implementation details.

    line 251

“Common” is measured: kept by at least 6 in 10 of the 33 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 - Quick Reference

Purpose: Comprehensive testing strategies for robust, reliable software across all layers.

When to use: Designing test plans, implementing automated tests, setting up CI/CD, improving coverage.


Modules

1. Testing Philosophy → 01-testing-philosophy.md

  • Test pyramid (60% unit, 30% integration, 10% E2E)
  • Coverage targets (critical paths 100%, business logic 90%+)
  • What to test vs. what NOT to test
  • Best practices and common pitfalls

2. Unit Testing → 02-unit-testing.md

  • pytest patterns (AAA, fixtures, parametrization)
  • Mocking (external APIs, databases)
  • Test isolation and independence
  • Example patterns with code

3. Integration Testing → 03-integration-testing.md

  • API integration tests (FastAPI TestClient)
  • Database integration (test databases, transactions)
  • Service integration (multi-component testing)
  • Test data management

4. Frontend Component Testing → 04-frontend-component-testing.md

  • React Testing Library (user-centric queries)
  • Svelte component tests
  • Async behavior (loading states, API calls)
  • Mocking context and hooks

5. E2E Testing → 05-e2e-testing.md

  • Playwright patterns (user journeys)
  • Browser automation
  • Critical path testing
  • When to use E2E vs component tests

6. Accessibility Testing → 06-accessibility-testing.md

  • WCAG 2.1 compliance (Level AA target)
  • Automated A11y (jest-axe, Playwright AxeBuilder)
  • Keyboard navigation testing
  • Manual testing checklist

7. Security Testing → 07-security-testing.md

  • OWASP Top 10 (injection, XSS, auth, CSRF)
  • API security (rate limiting, CORS)
  • SSRF prevention (DNS rebinding, TOCTOU)
  • Dependency scanning (pip-audit, npm audit)
  • SAST/DAST integration

8. AI/LLM Testing → 08-ai-llm-testing.md

  • Semantic assertions (never exact strings!)
  • JSON mode for deterministic testing
  • Prompt testing and variations
  • Cost/performance tracking

9. Performance Testing → 09-performance-testing.md

  • Load testing (Locust patterns)
  • Database performance (query timing)
  • Profiling and optimization

10. Flaky Test Management → 10-flaky-test-management.md

  • Identifying flaky tests (timing, non-determinism)
  • Common causes and fixes (sleep(), shared state)
  • Retry strategies (last resort!)
  • CI/CD handling (separate flaky tests)

11. CI/CD Integration → 11-ci-cd-integration.md

  • GitHub Actions patterns
  • Coverage reporting (codecov)
  • Test organization (unit/integration/e2e)
  • Quality gates

Quick Lookup

Common Tasks:

TaskModule
Writing pytest unit tests?02-unit-testing.md
Testing FastAPI endpoints?03-integration-testing.md
Testing React components?04-frontend-component-testing.md
Testing user flows?05-e2e-testing.md
Ensuring accessibility?06-accessibility-testing.md
Security testing?07-security-testing.md
Testing AI agents/LLMs?08-ai-llm-testing.md
Load/performance testing?09-performance-testing.md
Fixing flaky tests?10-flaky-test-management.md
Setting up CI/CD?11-ci-cd-integration.md

Testing Pyramid

        /\
       /  \  E2E Tests (10%)
      /----\
     /      \  Integration Tests (30%)
    /--------\
   /          \  Unit Tests (60%)
  /--------------\

Rule: More unit tests (fast, isolated), fewer E2E tests (slow, brittle).


Coverage Targets

LayerTarget Coverage
Critical Paths100%
Business Logic90-100%
API Endpoints80-90%
Utility Functions80-90%
UI Components70-80%

Measure: pytest --cov=src --cov-report=html


Anti-Patterns

Testing Implementation Details

Problem: Tests break when refactoring, not when behavior changes. Fix: Test behavior, not code structure. See 01-testing-philosophy.md

Flaky Tests

Problem: Tests fail randomly, destroying confidence. Fix: See 10-flaky-test-management.md for systematic fixes.

Exact LLM Output Assertions

Problem: LLMs are non-deterministic, exact strings fail. Fix: Use semantic assertions. See 08-ai-llm-testing.md

No Test Isolation

Problem: Tests depend on each other, fail in isolation. Fix: Use fixtures, clean up after tests. See 02-unit-testing.md

Skipping Security Tests

Problem: Vulnerabilities ship to production. Fix: Automate security scans. See 07-security-testing.md

Too Many E2E Tests

Problem: Slow test suite, brittle tests. Fix: Follow testing pyramid. See 01-testing-philosophy.md


When to Use Which Module

Planning test strategy?

→ Module 1 (Philosophy) - Understand pyramid, coverage, best practices

Writing backend tests?

→ Module 2 (Unit) + Module 3 (Integration)

Testing UI?

→ Module 4 (Component) for React/Svelte, Module 5 (E2E) for flows

Ensuring accessibility?

→ Module 6 (Accessibility) - WCAG compliance, keyboard nav

Testing security?

→ Module 7 (Security) - OWASP Top 10, injection, auth

Testing AI agents?

→ Module 8 (AI/LLM) - Semantic assertions, prompt testing

Performance issues?

→ Module 9 (Performance) - Load testing, profiling

Tests failing randomly?

→ Module 10 (Flaky Tests) - Identify and fix root causes

Setting up CI/CD?

→ Module 11 (CI/CD) - GitHub Actions, coverage, automation


Critical Reminders

LLM Testing (CRITICAL)

Never assert exact strings - LLMs are non-deterministic!

  • Use keyword presence: assert "Paris" in response
  • Use JSON mode: response_format="json" for structure
  • Use length bounds: assert 50 < len(response) < 200
  • Never: assert response == "Exact string"

See 08-ai-llm-testing.md for complete patterns.

Security Testing (CRITICAL)

Test negative cases - what should be blocked!

  • Test SQL injection payloads: "'; DROP TABLE users; --"
  • Test XSS: "<script>alert('XSS')</script>"
  • Test SSRF: Block private IPs (127.0.0.1, 169.254.169.254)
  • Automate scans: pip-audit, bandit, npm audit

See 07-security-testing.md for complete OWASP coverage.

Flaky Tests (CRITICAL)

Fix immediately - don't accumulate flaky tests!

  • Never use sleep() - use explicit waits
  • Never share state - use fixtures for isolation
  • Never depend on test order - each test independent
  • Goal: 0% flaky tests

See 10-flaky-test-management.md for systematic fixes.


Best Practices Checklist

  • Follow testing pyramid (more unit, fewer E2E)
  • Write tests during development (TDD/BDD)
  • Keep tests independent and isolated
  • Use descriptive test names (test_user_email_validation_rejects_invalid_format)
  • Mock external dependencies (APIs, databases in unit tests)
  • Use test fixtures and factories
  • Maintain >80% coverage (critical paths 100%)
  • Run tests in CI/CD pipeline
  • Keep unit tests fast (<1s each)
  • Test edge cases and error scenarios
  • Clean up test data after tests
  • Never ignore flaky tests - fix or skip with tracking issue
  • Never assert exact LLM strings - use semantic assertions
  • Always test security - OWASP Top 10, negative cases

Module Organization

Each module follows this structure:

  1. Introduction: When to use this testing approach
  2. Patterns: Code examples and best practices
  3. Anti-patterns: Common mistakes to avoid
  4. Checklist: Verification steps
  5. Cross-references: Links to related modules

Navigation: Always load SKILL.md first for quick reference, then specific module for implementation details.

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.