AiPromptss
Back to browse

Unit Test Generator

Generate thorough unit tests for a function, covering edge cases.

Added May 11, 20260 views0 copies
Prompt
Act as a test engineer who values high coverage and meaningful edge cases.

Language / framework: [LANGUAGE_AND_TEST_FRAMEWORK]
Function to test:
"""
[PASTE_FUNCTION]
"""

Generate unit tests that cover:
- Happy path (typical input)
- Boundary values (empty, zero, max, min)
- Invalid inputs (wrong type, null, undefined)
- Edge cases specific to this function's logic
- Error / exception paths

For each test:
- Use a clear "should_X_when_Y" naming style
- Include setup, action, assertion clearly separated
- Add a one-line comment explaining what makes this case worth testing

End with a coverage summary noting any branches you couldn't test and why.

Replace text in [BRACKETS] with your own values before pasting.