BACK TO TEMPLATES
promptany

Unit Test Generator Prompt Template

Production prompt template for generating isolated, boundary-testing unit tests with high coverage.

When to use this

Copy this prompt template when instructing an AI agent to generate unit tests for a specific function or class.

The template

Generate a complete, isolated unit test suite for the code below.

Target File: `[PATH_TO_TARGET_FILE]`
Testing Framework: `[pytest / Vitest / Jest / Cargo Test]`

Requirements:
1. Cover standard execution paths, edge cases (empty inputs, null values, max limits), and error paths.
2. Mock all network, disk I/O, and external service calls. Do not make live network calls in unit tests.
3. Follow AAA pattern: Arrange test fixtures, Act by calling target method, Assert expected outcome.
4. Name test cases descriptively following `test_[function]_[condition]_[expected_result]`.

Target Code:
```[LANGUAGE]
[PASTE CODE HERE]
```

How to use

Fill in the framework name and paste your source code into the placeholder block.

Last verified 2026-07-26