Gerador de casos de teste abrangentes para qualquer função ou funcionalidade

Why this prompt matters
Most developers write the happy-path test and call it done. This prompt forces a systematic sweep of the full input space in under a minute, catching the bugs that slip through code review.
What we use it for
Generate a complete test suite for any function or feature — unit tests, edge cases, error scenarios, and integration outlines in one shot.
Prompt
You are an expert software engineer specializing in test-driven development. Given the following function or feature description, generate a comprehensive test suite covering: 1. Unit tests — standard inputs, boundary values, and typical use cases 2. Edge cases — null/undefined inputs, empty arrays/strings, maximum/minimum values 3. Error scenarios — invalid types, out-of-range values, missing required fields, network failures if applicable 4. Integration considerations — interactions with databases, APIs, or external services if mentioned For each test case provide: - A descriptive test name - Preconditions (if any) - Input values - Expected output or behavior - A one-sentence explanation of why this case matters Function/Feature to test: [PASTE YOUR FUNCTION OR FEATURE DESCRIPTION HERE] Language/Framework (optional): [e.g., Python/pytest, JavaScript/Jest, TypeScript/Vitest]
O Prompt
Cole isso junto com a descrição da sua função no Claude, GPT-4 ou qualquer LLM capaz:
You are an expert software engineer specializing in test-driven development. Given the following function or feature description, generate a comprehensive test suite covering:
1. Unit tests — standard inputs, boundary values, and typical use cases
2. Edge cases — null/undefined inputs, empty arrays/strings, maximum/minimum values
3. Error scenarios — invalid types, out-of-range values, missing required fields, network failures if applicable
4. Integration considerations — interactions with databases, APIs, or external services if mentioned
For each test case provide:
- A descriptive test name
- Preconditions (if any)
- Input values
- Expected output or behavior
- A one-sentence explanation of why this case matters
Function/Feature to test:
[PASTE YOUR FUNCTION OR FEATURE DESCRIPTION HERE]
Language/Framework (optional): [e.g., Python/pytest, JavaScript/Jest, TypeScript/Vitest]Exemplo na prática
Para uma função como getUserById(id) que busca um usuário de um banco de dados, este prompt gera casos de teste cobrindo: IDs válidos, IDs inexistentes, usuários deletados de forma suave, UUIDs malformados, cenários de timeout do banco de dados e leituras concorrentes.
Dicas para melhores resultados
- Inclua a assinatura da função — mesmo que aproximada. Anotações de tipo ajudam o modelo a gerar casos de borda específicos do tipo.
- Mencione efeitos colaterais — se a função escreve em um banco de dados ou envia e-mails, diga explicitamente.
- Nomeie seu framework — a saída muda de descrições abstratas para código de teste real na sintaxe escolhida.
Conclusão
Cobertura de testes abrangente é o passo mais consistentemente ignorado no desenvolvimento de software. Este prompt transforma um exercício mental de 30 minutos em uma tarefa de 30 segundos.