Unit Test Writer
Generate comprehensive test suites including edge cases.
Write a test suite for the following function using {test_framework}.
Requirements:
1. Cover the happy path
2. Cover all boundary conditions (empty, zero, negative, max)
3. Cover error handling (invalid inputs, exceptions)
4. Use descriptive test names in the style: "should <expected> when <condition>"
5. Follow Arrange-Act-Assert structure
6. Mock external dependencies with {mocking_library}
Function to test:
```{language}
{code}
```Customize This Prompt
Fill in the variables and the prompt updates automatically.
Example Input
test_framework: jest, mocking_library: jest.mock, language: typescript, code: a calculateDiscount function
Example Output
A complete test suite with happy-path, boundary, and error tests, descriptive names, and clean Arrange-Act-Assert blocks.
Why This Prompt Works
Explicit coverage categories (happy, boundary, error) prevent shallow tests, and the naming convention makes failures readable.
Tips for Best Results
- Review edge cases the model may have missed.
- Run the suite and add any failing-test fixes back into the prompt.
- Ask for coverage reports to find gaps.
Common Mistakes
- Tests that only assert the happy path.
- Mocking too much, making tests meaningless.
Related Prompts
Prompts that pair well with this one.
Senior Code Reviewer
Get a senior engineer to review your code for bugs, security, and readability.
Bug Buster
Debug code with root-cause analysis instead of guessing.
Prompt Perfector
Stress-test and improve prompts against failure cases.
Database Schema Architect
Design normalized, scalable database schemas with indexes and trade-offs.
Frequently Asked Questions
Can I use this prompt for free?
Yes. Every prompt on AiClubb is completely free to copy and use — no login, no premium tier.
Which AI models work best with this prompt?
This prompt is optimized for Claude, but it works on any modern model. Test it across models and keep the output you like best.
How do I customize the variables?
Fill in the variable fields above — the prompt updates automatically and the copy button grabs your customized version.
Can I save this prompt?
Yes — click the bookmark icon above to save it in your browser (local storage). Your saved prompts are private to your device.