Intermediate
Best DeepSeek Prompt for Tests & Docs
Why DeepSeek?
DeepSeek generates complete, runnable test suites with edge cases and writes structured API documentation. Its reasoning chain identifies non-obvious edge cases (null inputs, boundary values, concurrent access) that simple prompt tools miss.
Prompt Template
你是一位测试工程师和技术文档专家。请为以下代码生成完整的单元测试和API文档。\n\n编程语言/框架:{{language_framework}}\n代码:\n```\n{{code}}\n```\n\n**任务一:单元测试**\n请生成覆盖以下场景的测试用例:\n1. 正常路径(Happy Path)— 典型正确输入\n2. 边界值测试 — 极值、空值、零值\n3. 异常场景 — 非法输入、异常应如何抛出/处理\n4. 你认为开发者可能忽略的隐藏边界情况\n\n每个测试用例请包含:测试名称、测试描述、断言逻辑\n\n**任务二:API文档**\n按以下格式输出:\n- 函数/接口名称\n- 功能描述(一句话)\n- 参数说明(名称、类型、是否必填、含义)\n- 返回值(类型、结构、含义)\n- 异常/错误码说明\n- 调用示例\n\n{{extra_notes}} Example Output
**单元测试:**\n```python\nimport pytest\nfrom math_utils import divide\n\ndef test_divide_normal():\n """正常除法"""\n assert divide(10, 2) == 5.0\n\ndef test_divide_float():\n """浮点数除法"""\n assert abs(divide(1, 3) - 0.3333) < 0.0001\n\ndef test_divide_by_zero():\n """除数为零应抛出ValueError"""\n with pytest.raises(ValueError, match="除数不能为零"):\n divide(10, 0)\n\ndef test_divide_negative():\n """负数除法"""\n assert divide(-10, 2) == -5.0\n\ndef test_divide_zero_numerator():\n """被除数为零"""\n assert divide(0, 5) == 0.0\n\ndef test_divide_very_large():\n """极大值不应溢出"""\n result = divide(1e308, 1)\n assert result == 1e308\n```\n\n**API文档:**\n`divide(a, b)` — 对两个数执行浮点除法。\n- 参数:`a: float`(被除数,必填);`b: float`(除数,必填,不可为0)\n- 返回:`float`,商\n- 异常:`ValueError` — 当 b == 0 时抛出
Make it yours
Your Generated Prompt
Prompt copied! What's next?
Got your AI output? Make it better.
Paste what DeepSeek generated into Coda One — free, no signup.
Tips for Better Results
Generating tests and documentation together is more efficient. Specify your testing framework version (e.g., pytest 7.x vs 8.x) to avoid API differences that break the generated code.
Example (filled in)
你是一位测试工程师和技术文档专家。\n\n编程语言/框架:Python + pytest\n\n代码:\n```python\ndef divide(a: float, b: float) -> float:\n if b == 0:\n raise ValueError("除数不能为零")\n return a / b\n```