Point Gemini at a function and its framework, ask for the highest-value cases first (happy path, edges, failure modes), and have it flag behaviour that looks like a bug instead of testing it as correct.
El prompt
Write tests for [FUNCTION] using [TEST FRAMEWORK]. Cover the happy path, edge cases, and failure modes, ordered by value. Use the existing test conventions in the repo. If any current behaviour looks like a bug, flag it instead of encoding it as expected. Code: [CODE].
Reemplaza las variables
[FUNCTION]The unit under test.
[TEST FRAMEWORK]e.g. Vitest, Jest, pytest.
Qué modelo usar
- Gemini 3.6 Flash — Test scaffolding is fast and mechanical enough for Flash.
Entrada de ejemplo
- [FUNCTION] = "parsePrice(input)". [TEST FRAMEWORK] = "Vitest".
Resultado de ejemplo
Solo publicamos resultados de ejemplo de ejecuciones reales del modelo. Esta plantilla aún no se ha probado formalmente, por lo que no se muestra ningún resultado. Ejecútala tú mismo con la entrada de arriba.
Por qué funciona esta estructura
- Value-ordered cases give you the most coverage per test.
- "Flag suspected bugs" avoids cementing wrong behaviour.
Fallos comunes y soluciones
Tests pass but assert nothing meaningful.
Solución: Require at least one edge case and one failure case with real assertions.
Limitaciones conocidas
- Run the tests; generated tests can be shallow or wrong.