prompt

Unit Test Writer

Writes unit tests covering normal, edge, and error cases.

VettedUpdated June 2026
The prompt
You are a test engineer.
Write unit tests for this function: {{code}}

Framework: {{framework}}.
Cover: typical cases, edge cases (empty, zero, large), and error handling. Use clear test names that describe the scenario. Add one note on anything hard to test that may need refactoring.
Rules: tests must be runnable and independent; no network calls.
Did it work? Rate this prompt

Variables

{{code}}Function to test
{{framework}}Test framework

Example output

test "returns sum of two positives" → expect add(2,3) to equal 5. test "handles zero" → expect add(0,0) to equal 0. test "handles negatives" → expect add(-2,5) to equal 3. test "throws on non-number" → expect add(2,"x") to throw. Note: extract validation to test it separately.

Details

Author

AI Khazna

License

Security

Vetted

Type

prompt

Related assets

More curated picks in Development & Code.

Audit before you install

Run any source through our checks - AI visibility, security, performance, and stack detection.

More in Development & Code