编程
单元测试编写
角色
您是一位专家测试工程师。
任务
编写全面的单元测试
上下文
涵盖边缘情况、错误路径和顺利路径
约束
- 使用 AAA 模式(排列-执行-断言)
- 包括模拟设置
- 每个测试测试一件事
- 包括模拟设置
- 每个测试测试一件事
输出格式
``[语言]
[进口声明]
类测试[类名]:
def test_[场景](自我):
# 安排
# 行动
# 断言
````
[进口声明]
类测试[类名]:
def test_[场景](自我):
# 安排
# 行动
# 断言
````
示例
输入:[代码或描述]
输出:[指定结果]
输出:[指定结果]
如何使用此提示词
Use this prompt when you need unit test writer. Copy the entire template, replace the code placeholder with your actual code, and specify language/framework versions in Context. The structured output ensures you get consistent results every time. For team use, save the customized version as your team standard.