Genera una suite de tests completa a partir de cualquier función o descripción de funcionalidad

Why this prompt matters
<p>Incomplete tests are the leading cause of regressions in production. A typical developer writing tests from memory covers 60-70% of edge cases — the remaining 30% is where bugs live. Every missed edge case is a future incident, a 2am page, or a data corruption bug discovered by a customer. Beyond bugs: code without proper tests blocks confident refactoring. You end up with unmaintainable spaghetti because nobody dares touch it. This prompt forces systematic coverage across happy paths, boundaries, failures, and integration points — the same coverage a dedicated QA engineer would produce in several hours, generated in under a minute.</p>
What we use it for
You wrote a function or shipped a feature and need full test coverage before merging. You have the code in front of you but writing tests feels slow — you keep forgetting edge cases and your PR review always comes back with 'what about null input?' or 'does this handle timeout?'
Prompt
Act as a senior software engineer and QA architect with deep expertise in test-driven development. Context: I have a [FUNCTION / FEATURE / MODULE] that I need fully tested. It is written in [PROGRAMMING LANGUAGE] and uses [FRAMEWORK / LIBRARY if any]. Here is the code or description: [PASTE YOUR FUNCTION OR FEATURE DESCRIPTION HERE] Task: Generate a comprehensive test suite for the above. Cover ALL of the following: 1. Happy-path unit tests 2. Edge case unit tests 3. Error/failure scenarios 4. Integration test outlines 5. Security-relevant tests if applicable Constraints: - Write tests in [TEST FRAMEWORK, e.g. Jest, pytest, JUnit] - Name tests: should_[expected behavior]_when_[condition] - Do NOT write implementation code - Group tests into describe blocks by category - Flag any testability issues in the original code Output Format: - Full runnable test file with all imports - Section comments: // === HAPPY PATH ===, // === EDGE CASES ===, etc. - Summary table: test count per category + estimated code coverage % - Testability issue flags
El problema de escribir pruebas a mano
Pregunta a cualquier desarrollador qué es lo que suele saltarse cuando tiene plazos ajustados, y las pruebas aparecen siempre. Escribir pruebas exhaustivas es tedioso y mentalmente agotador. La mayoría de los desarrolladores se pierden entre un 30 y un 40% de los casos límite relevantes.
Este Prompt soluciona eso al incorporar el pensamiento sistemático de un ingeniero de QA senior en una plantilla reutilizable.
Qué hace efectivo a este Prompt
El Prompt utiliza un Framework de cobertura de cinco categorías: camino feliz, casos límite, errores, integración y seguridad. La restricción de nombrar las pruebas usando should_[behavior]_when_[condition] obliga a la IA a ser precisa. El requisito de señalar problemas de testabilidad captura problemas arquitectónicos antes de que se conviertan en deuda técnica.
Cómo usarlo
Pega el Prompt en Claude Sonnet 4.5 (o GPT-4o). Completa los tres campos: tu lenguaje, tu Framework de pruebas y la descripción de la función. El resultado es un archivo de pruebas listo para ejecutar y una tabla resumen de cobertura.
Adaptación a distintos lenguajes y Frameworks
Para Python usa pytest. Para TypeScript, Jest o Vitest. Para Java, JUnit 5. Para Go, Go testing package.