Write unit tests for an existing module

Software testing promptsDifficulty: Beginner Last updated: 16 November 2026

Usage description

Increase coverage with meaningful tests for normal and edge cases.

Prompt text

Prompt
Write unit tests for {{extra}} in {{project}} using {{stack}}.
- Read the code first and write a list of the behaviours to test.
- Cover: the normal case, boundaries, invalid input and expected errors.
- Use mocks only for external boundaries (network, time, database).
- Test names that describe the behaviour.
- Run the tests and show me the result and the actual line coverage.
- If you find a bug in the code while testing, tell me, and do not change the test so it passes.

Required inputs

The module and the test framework.

Expected outputs

A test file, the run result and the coverage.

Suitable tools

Practical example

stack = "pytest", extra = "utils/dates.py".

Rate:
No ratings yet

We do not claim this prompt was tested on a particular model; results vary with the model and context, so always review the output.

Create a custom version with AI

Do not write secrets, keys or personal data. The description is merged with the prompt directly, without sending it to any external service.