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.
Il 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].
Sostituisci le variabili
[FUNCTION]The unit under test.
[TEST FRAMEWORK]e.g. Vitest, Jest, pytest.
Quale modello usare
- Gemini 3.6 Flash — Test scaffolding is fast and mechanical enough for Flash.
Input di esempio
- [FUNCTION] = "parsePrice(input)". [TEST FRAMEWORK] = "Vitest".
Output di esempio
Pubblichiamo output di esempio solo da esecuzioni reali del modello. Questo template non è ancora stato testato formalmente, quindi non viene mostrato alcun output. Eseguilo tu stesso con l'input qui sopra.
Perché questa struttura funziona
- Value-ordered cases give you the most coverage per test.
- "Flag suspected bugs" avoids cementing wrong behaviour.
Errori comuni e soluzioni
Tests pass but assert nothing meaningful.
Soluzione: Require at least one edge case and one failure case with real assertions.
Limiti noti
- Run the tests; generated tests can be shallow or wrong.