تولیدکننده جامع موارد تست برای هر تابع یا ویژگی

Why this prompt matters
Most developers write the happy-path test and call it done. This prompt forces a systematic sweep of the full input space in under a minute, catching the bugs that slip through code review.
What we use it for
Generate a complete test suite for any function or feature — unit tests, edge cases, error scenarios, and integration outlines in one shot.
Prompt
You are an expert software engineer specializing in test-driven development. Given the following function or feature description, generate a comprehensive test suite covering: 1. Unit tests — standard inputs, boundary values, and typical use cases 2. Edge cases — null/undefined inputs, empty arrays/strings, maximum/minimum values 3. Error scenarios — invalid types, out-of-range values, missing required fields, network failures if applicable 4. Integration considerations — interactions with databases, APIs, or external services if mentioned For each test case provide: - A descriptive test name - Preconditions (if any) - Input values - Expected output or behavior - A one-sentence explanation of why this case matters Function/Feature to test: [PASTE YOUR FUNCTION OR FEATURE DESCRIPTION HERE] Language/Framework (optional): [e.g., Python/pytest, JavaScript/Jest, TypeScript/Vitest]
پرامپت
این متن را به همراه توضیح تابعتان در Claude، GPT-4 یا هر مدل زبانی توانمندی وارد کنید:
You are an expert software engineer specializing in test-driven development. Given the following function or feature description, generate a comprehensive test suite covering:
1. Unit tests — standard inputs, boundary values, and typical use cases
2. Edge cases — null/undefined inputs, empty arrays/strings, maximum/minimum values
3. Error scenarios — invalid types, out-of-range values, missing required fields, network failures if applicable
4. Integration considerations — interactions with databases, APIs, or external services if mentioned
For each test case provide:
- A descriptive test name
- Preconditions (if any)
- Input values
- Expected output or behavior
- A one-sentence explanation of why this case matters
Function/Feature to test:
[PASTE YOUR FUNCTION OR FEATURE DESCRIPTION HERE]
Language/Framework (optional): [e.g., Python/pytest, JavaScript/Jest, TypeScript/Vitest]مثال کاربردی
برای تابعی مثل getUserById(id) که کاربر را از پایگاه داده واکشی میکند، این پرامپت موارد تست زیر را تولید میکند: شناسههای معتبر، شناسههای ناموجود، کاربران حذفشده نرم، UUIDهای نامعتبر، تایماوت پایگاه داده و خواندنهای همزمان — مواردی که توسعهدهنده تحت فشار زمانی معمولاً از آنها صرفنظر میکند.
نکاتی برای نتایج بهتر
- امضای تابع را وارد کنید — حتی به صورت تقریبی. حاشیهنویسی نوع به مدل کمک میکند موارد مرزی مرتبط با نوع را شناسایی کند.
- عوارض جانبی را ذکر کنید — اگر تابع در پایگاه داده مینویسد یا ایمیل ارسال میکند، آن را صراحتاً بیان کنید.
- فریمورک خود را نام ببرید — خروجی از توضیحات انتزاعی به کد تست واقعی در سینتکس انتخابی شما تبدیل میشود.
نتیجهگیری
پوشش جامع تست یکی از پرتکرارترین مراحلی است که در توسعه نرمافزار از آن چشمپوشی میشود. این پرامپت یک تمرین ذهنی ۳۰ دقیقهای را به یک فرآیند ۳۰ ثانیهای تبدیل میکند.