Generador de casos de prueba completos para cualquier función o característica

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]
El Prompt
Pega esto junto con la descripción de tu función en Claude, GPT-4 o cualquier 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]Ejemplo en la práctica
Para una función como getUserById(id) que obtiene un usuario de una base de datos, este prompt genera casos de prueba que cubren: IDs válidos, IDs inexistentes, usuarios eliminados de forma suave, UUIDs malformados, escenarios de tiempo de espera de base de datos y lecturas concurrentes.
Consejos para mejores resultados
- Incluye la firma de la función — aunque sea aproximada. Las anotaciones de tipo ayudan al modelo a generar casos límite específicos del tipo.
- Menciona los efectos secundarios — si la función escribe en una base de datos o envía correos electrónicos, indícalo explícitamente.
- Nombra tu framework — el resultado cambia de descripciones abstractas a código de prueba real en la sintaxis elegida.
Conclusión
La cobertura de pruebas exhaustiva es el paso más omitido en el desarrollo de software. Este prompt convierte un ejercicio mental de 30 minutos en uno de 30 segundos.