ThinkKit Works
All notes
AI for QA

Prompt Patterns for Test Generation That Actually Work

Reusable prompt patterns that make an LLM produce useful, structured test cases instead of vague suggestions — with the guardrails that keep it honest.

2 min read
AIPromptingTest DesignPatterns

Most disappointing AI test generation comes down to lazy prompting. “Write test cases for this” gets you generic filler. A few reusable patterns turn the same model into a fast, structured test-design assistant.

Pattern 1 — Constrain the output shape

The single biggest improvement is telling the model exactly what structure to return. A defined shape forces completeness and makes the output paste-ready.

Return a table with columns: id | type | precondition | steps | expected.
Group rows under: Positive, Negative, Boundary, Security.

Without a shape, the model rambles. With one, it fills a grid — and empty cells reveal gaps you can question.

Pattern 2 — Give it the acceptance criteria, verbatim

The model cannot test requirements it was never shown. Paste the user story and acceptance criteria exactly, and instruct it to map each criterion to at least one test. This anchors the output to real requirements instead of the model’s assumptions.

Pattern 3 — Ask for the negative space

LLMs default to happy paths. You have to explicitly pull the rest out:

  • “List the ways this feature could fail that the requirements don’t mention.”
  • “What inputs would a malicious user try here?”
  • “Which boundary values are most likely to break this?”

These prompts surface the cases that separate a real tester from an autocomplete.

Pattern 4 — Force an “Open Questions” section

This is the honesty guardrail. Instruct the model:

If any requirement is ambiguous or missing, do not guess — list it under “Open Questions” instead of inventing a test.

This converts the model’s tendency to hallucinate into a list of clarifications for the product owner — the single most valuable output, because it catches gaps before code is written.

Pattern 5 — Iterate, don’t one-shot

Treat generation as a conversation. A strong second turn:

  • “Merge duplicates and remove any case not tied to a requirement.”
  • “Now rank these by risk and mark the top 5 as smoke tests.”

The first pass gives breadth; follow-ups add the judgment.

What still needs a human

These patterns make the model a fast first-drafter, not a decision-maker. You still own:

  • Whether a generated case reflects a real business rule
  • Which cases are worth automating versus running once
  • The domain knowledge the model was never given

The takeaway

Good AI test generation is a skill, and the skill is mostly in the prompt. Constrain the shape, feed real criteria, demand the negative space, and force open questions — and the model stops being a novelty and becomes a genuine accelerator for test design.

Related

More in AI for QA