Prompt
AI Test Generation Prompt
Generates behavioural tests and edge cases, not tautologies.
1 min readupdated 2026-08-01
/ quick answer
Use when adding coverage to existing code or a new AI feature. Generates behavioural tests and edge cases, not tautologies.
Generates behavioural tests and edge cases, not tautologies. Use when adding coverage to existing code or a new AI feature. Copy the prompt below, swap the bracketed variables for your own context, and run it in any capable model. This prompt node is part of the Onexial knowledge graph and links to related concepts, workflows and tools below.
Context
Use when adding coverage to existing code or a new AI feature.
Prompt
Generate tests for the code below. Rules:
- Test behaviour and contracts, never implementation details.
- No snapshot tests of model output.
- Include edge cases: empty, null, malformed, boundary, concurrent, very large input.
- For AI features, assert structure and required facts, not exact wording.
- Each test name states the behaviour being guaranteed.
Return:
1. The test file, runnable in {{TEST_FRAMEWORK}}.
2. A list of behaviours you could NOT test and why.
3. Bugs you noticed in the code while writing the tests.
Code: {{CODE}}
Expected behaviour: {{BEHAVIOUR}}Example Output
1. describe('parseInvoice') → it('rejects a document whose line items do not sum to the total')...Related Workflow
Related Tool Stacks
/ frequently asked
What does the AI Test Generation Prompt prompt do?
Use when adding coverage to existing code or a new AI feature.
Which AI models work with this prompt?
It is model-agnostic: it works with any capable general model. Replace the bracketed variables with your own context before running it.
What output should I expect?
1. describe('parseInvoice') → it('rejects a document whose line items do not sum to the total')...
↳ connected nodes
Workflow↳ linked
Build a Test Suite for a Non-Deterministic AI Feature
Grade probabilistic output without brittle snapshot tests.
Tool Stack↳ linked
AI Testing Stack
Test deterministic code and probabilistic AI output in one pipeline.
Dictionary↳ linked
AI Testing
AI testing covers two things: using AI to generate and maintain tests, and testing AI systems whose output is non-deterministic.
Prompt↳ linked
Coding Agent Task Spec Prompt
Writes the task brief that keeps a coding agent inside scope.
Prompt↳ linked
AI Code Review Rubric Prompt
A reviewer prompt that finds real defects instead of style opinions.
Prompt↳ linked
Prompt Improver Prompt
Iterate a weak prompt into a strong one using best practices.