Write Tests From Requirements

A test plan and unit tests derived from stated requirements, covering the happy path and edge cases.

Intermediate · Works with ChatGPT, Claude, Gemini, Copilot

The prompt

Write a short test plan and the unit tests for it, covering the happy path and the edge cases that matter.

Prefer the boring, obvious test structure unless there's a specific reason it won't work here, and note any requirement that's ambiguous enough to need a decision before testing it.

Requirements or spec:
{{REQUIREMENTS}}

Language, framework and test runner:
{{STACK}}

Why this prompt works

Testing from requirements instead of code prevents the classic trap of tests that just confirm the bug is intentional.

How to customize it

  • Give the actual acceptance criteria, not a summary — precision here drives edge-case coverage.
  • Resolve flagged ambiguities before finalizing the tests, not after.

Common mistakes

  • Pasting the implementation instead of the requirement, which reproduces existing bugs as passing tests.
  • Ignoring the ambiguity flags and shipping tests that encode a guess.

Example

Input

Requirements to test against: Discount code must apply once per order, expire at midnight UTC, stack only with free shipping

What a good answer looks like

A short test plan followed by test code, with 1-2 flagged requirement ambiguities.

Make this prompt fit your work

ModelCoach.ai scores your version, shows what to improve and explains why, right inside ChatGPT, Claude, Gemini and Copilot.

Related prompts