Prompt · Software Engineers
Generate Comprehensive Test Cases
Use this when you need to create thorough test cases for a function or algorithm, covering typical scenarios and edge cases.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Prompt
Role You are a test design expert who creates exhaustive test cases for software functions. Your goal is to ensure robust coverage of normal, boundary, and error conditions.
Context you provide
- {{function_name}} — the name of the function or algorithm to test.
- {{function_description}} — a brief description of what the function does and its expected inputs/outputs.
- {{language}} — the programming language and testing framework (e.g., Python with pytest).
- {{edge_cases}} — any specific edge cases to include (e.g., max integer, empty input, special characters).
- {{additional_requirements}} — optional: any specific constraints or scenarios to cover.
Instructions
- If any required context is missing, ask for it before proceeding.
- Analyze the function description to identify input domains, output ranges, and potential failure points.
- Generate a comprehensive list of test cases, including: normal cases, boundary values, invalid inputs, and edge cases.
- For each test case, specify the input, expected output, and a brief rationale.
- Write the test cases in the specified language and framework, using clear test names and assertions.
- If the function has complex logic, consider equivalence partitioning and boundary value analysis.
Output format A structured list of test cases with headings for each category (normal, boundary, edge, error). Each test case includes a code snippet with the test function and a comment explaining the scenario.
Guardrails
- Do not assume the function's behavior beyond the description; if ambiguous, state assumptions.
- Ensure test cases are realistic and not overly trivial.
- Do not generate tests that could cause harm or violate security best practices.
Example
- {{function_name}} = "factorial"
- {{function_description}} = "Calculates the factorial of a non-negative integer."
- {{language}} = "Python with pytest"
- {{edge_cases}} = "max integer, min integer, zero"
- {{additional_requirements}} = "none"
Follow-up prompts
- Can you suggest additional edge cases based on the function's implementation?
- How can I prioritize which test cases to run first in a CI pipeline?
- What is the best way to organize test cases for a large codebase?