agentleFS
BappozBappoz/My-Claude-Skills/skills/engineering/testing/SKILL.md

testing

Skill1 starsChanged 5 months agoMITView on GitHub

Estratégia e escrita de testes production-grade: pirâmide vs troféu, unit/integration/e2e, o que testar (comportamento, não implementação), test doubles, contract e mutation testing, cobertura útil. Use quando o usuário mencionar: "como testar", "escrever testes", "estratégia de testes", "cobertura", "test plan", "TDD", "mock vs stub", "teste e2e", "teste de integração", "flaky test".

123 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use oss-pr, pr-automation and 9 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.
  • CES-LtdSkill

    oss-pr

    Use when creating a pull request, after committing changes, or when user invokes /oss-pr. Covers branch management, quality checks, commit, push, and PR creation.

    Also in 3 projects that use this

  • CES-LtdSkill

    pr-automation

    PR Automation Orchestrator: poll open PRs, check CI, run review, fix, and merge eligible PRs. Use when: (1) Invoked by daemon via scripts/pr-automation.sh, (2) User says "/pr-automation".

    Also in 3 projects that use this

  • ffsshhttiikkSkill

    cicd

    Continuous integration and delivery pipelines

    Also in 4 projects that use this

  • ffsshhttiikkSkill

    networking

    Practical application and coding skills for Networking

    Also in 3 projects that use this

  • Cogni-AI-OUSkill

    dotfiles

    Reference for repository dotfiles, including their purposes, standard configurations, and usage guidelines. You MUST load this skill when configuring, troubleshooting, or understanding repository dotfiles.

    Also in 3 projects that use this

  • pluginagentmarketplaceSkill

    microservices

    Microservices architecture patterns and best practices. Service decomposition, inter-service communication, and distributed data management.

    Also in 3 projects that use this

  • +2 more from CES-Ltd
  • +1 more from ffsshhttiikk

The file

Files
SKILL.md

Testing

Você atua como engenheiro que trata testes como parte do design, não como imposto. Objetivo: testes que dão confiança para mudar o código — rápidos, determinísticos e focados em comportamento observável.

Princípio central: teste comportamento, não implementação

Um teste bom falha quando o comportamento quebra e sobrevive a refatoração interna. Se mudar o "como" (sem mudar o "o quê") quebra o teste, ele testa a coisa errada.

Qual formato — troféu > pirâmide (para a maioria dos apps)

      /\        e2e        poucos, caros, lentos — fluxos críticos ponta a ponta
     /  \
    /----\   integration   MUITOS — onde vive a confiança real (módulos + I/O reais/próximos)
   /------\
  /--------\    unit        muitos — lógica pura, ramos, edge cases
 /----------\  static      grátis — types, lint, format (pega classe inteira de bugs)
  • Static (TypeScript, lint) elimina bugs sem escrever teste — use ao máximo.
  • Integration dá o melhor retorno de confiança por esforço na maioria dos backends/UI.
  • e2e só para os poucos fluxos que, se quebrarem, é incidente (login, checkout).

O que testar

PriorizeDespriorize
Regras de negócio e edge casesGetters/setters triviais
Fronteiras (0, 1, N, vazio, nulo, limite)Código de framework
Caminhos de erro e falha100% de cobertura como meta
Contratos entre módulos/serviçosDetalhes de implementação privada

Test doubles (use o nome certo)

  • Stub — respostas prontas para input (controla o "vindo de").
  • Mock — verifica interação (que foi chamado como esperado).
  • Fake — implementação leve real (ex: DB em memória).
  • Spy — registra chamadas sem alterar comportamento. Regra: prefira fakes reais a mocks; mock demais = teste acoplado à implementação.

Testes que valem a pena

  • Determinísticos — sem relógio real, sem rede real não controlada, sem ordem dependente. Flaky test é dívida que corrói confiança → conserte ou delete.
  • Rápidos — suíte de unit/integration em segundos; se dói rodar, ninguém roda.
  • Isolados — cada teste monta e derruba seu estado.
  • AAA — Arrange, Act, Assert; uma asserção lógica por teste.
  • Nome descreve o comportamento — deve rejeitar saque acima do saldo.

Técnicas avançadas (quando compensa)

  • Contract testing (Pact) — garante que serviços que se integram concordam no contrato sem e2e caro.
  • Property-based (fast-check/Hypothesis) — gera centenas de inputs; ótimo para lógica pura/parsing.
  • Mutation testing (Stryker/PIT) — mede se seus testes pegam bugs, não só cobertura de linha.
  • Snapshot — útil para output estável (UI/serialização); revise diffs, não aprove cego.

Fluxo

  1. Defina o comportamento observável a garantir.
  2. Escolha o nível mais barato que dá a confiança (static → unit → integration → e2e).
  3. Escreva o teste (TDD: antes do código quando o design está incerto).
  4. Cubra edge cases e caminhos de erro.
  5. Rode; garanta determinismo; mate flakiness.

Recursos externos

RecursoO que pegar
Testing Trophy (Kent C. Dodds)Por que integration > unit para apps.
Testing LibraryTestar UI pelo comportamento do usuário, não por implementação.
Playwrighte2e moderno, confiável, com auto-wait (menos flaky).
Martin Fowler — Test Double / Mocks aren't StubsVocabulário correto de doubles.
Google Testing BlogPráticas de escala (small/medium/large, flakiness).
Pact (contract testing)Contratos consumer-driven entre serviços.

Do / Don't

DoDon't
Testar comportamento observávelTestar detalhe interno
Fakes reaisMock de tudo
Consertar/deletar flakyConviver com flaky
Cobrir edge cases e errosPerseguir 100% de linha

Checklist

  • Comportamento (não implementação) sendo verificado
  • Nível escolhido é o mais barato que dá confiança
  • Edge cases e caminhos de erro cobertos
  • Testes determinísticos e isolados (zero flaky)
  • Nomes descrevem comportamento
  • Static analysis (types/lint) ligada ao máximo

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.