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.
Le 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].
Remplacez les variables
[FUNCTION]The unit under test.
[TEST FRAMEWORK]e.g. Vitest, Jest, pytest.
Quel modèle utiliser
- Gemini 3.6 Flash — Test scaffolding is fast and mechanical enough for Flash.
Exemple d'entrée
- [FUNCTION] = "parsePrice(input)". [TEST FRAMEWORK] = "Vitest".
Exemple de sortie
Nous ne publions que des exemples de sorties issus d'exécutions réelles sur un modèle. Ce modèle n'a pas encore été formellement testé, aucune sortie n'est donc affichée. Exécutez-le vous-même avec l'entrée ci-dessus.
Pourquoi cette structure fonctionne
- Value-ordered cases give you the most coverage per test.
- "Flag suspected bugs" avoids cementing wrong behaviour.
Échecs courants et correctifs
Tests pass but assert nothing meaningful.
Correctif : Require at least one edge case and one failure case with real assertions.
Limites connues
- Run the tests; generated tests can be shallow or wrong.