Skip to main content
Testing

Write focused tests for existing code

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.

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].

Değişkenleri değiştirin

[FUNCTION]

The unit under test.

[TEST FRAMEWORK]

e.g. Vitest, Jest, pytest.

Hangi model kullanılmalı

  • Gemini 3.6 FlashTest scaffolding is fast and mechanical enough for Flash.

Örnek girdi

  • [FUNCTION] = "parsePrice(input)". [TEST FRAMEWORK] = "Vitest".

Örnek çıktı

Yalnızca gerçek model çalıştırmalarından elde edilen örnek çıktıları yayınlarız. Bu şablon henüz resmi olarak test edilmediğinden hiçbir çıktı gösterilmiyor. Yukarıdaki girdiyle kendiniz çalıştırın.

Bu yapı neden işe yarar

  • Value-ordered cases give you the most coverage per test.
  • "Flag suspected bugs" avoids cementing wrong behaviour.

Sık karşılaşılan hatalar ve düzeltmeler

Tests pass but assert nothing meaningful.

Düzeltme: Require at least one edge case and one failure case with real assertions.

Bilinen sınırlamalar

  • Run the tests; generated tests can be shallow or wrong.

Google ile bağlantılı veya onun tarafından desteklenmiyor. Gemini, Nano Banana ve Veo, Google LLC'nin ticari markalarıdır.