CodingUpdated 2026-10-23
Unit Test Generation Prompt
Generate runnable tests with edge cases, not just the happy path.
#单元测试#测试#工程#边界条件Claude CodeCursorAider
Prompt
Write unit tests for the function below.
Language/framework: {{language/framework}}
Function:
```
{{function code}}
```
Requirements:
1. List inputs/outputs and five edge cases first.
2. Cover happy path, empty, extremes, invalid input, and exceptions.
3. One assertion per behavior; clear names.
4. Use table-driven/parameterized tests when supported.
5. Don't mock the function under test.
6. End with the run command.Variables to replace
{{语言/框架}}{{函数代码}}
Example output
TestParseAmount_Empty_ReturnsError: empty input should return ErrEmpty.
How to use it
Ask for an edge-case list before test code; coverage improves.
Recommended tools
Related prompts
CodingFeatured
Code Review Prompt
Have the model review code by severity and return actionable fixes.
Claude CodeCursorGitHub Copilot
Coding
Code review prompt for Enterprise Software
A code review template for enterprise IT and digital leads, addressing long procurement cycles and complex integration and delivering issue list (severity, location, cause, fix).
ClaudeGPTDeepSeek
Coding
Code review prompt for B2B SaaS
A code review template for SMB buyers and business leads, addressing high acquisition costs and low trial conversion and delivering issue list (severity, location, cause, fix).
ClaudeGPTDeepSeek