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.