456
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')...