Claude Sonnet 4.5 (also works with GPT-4o and Gemini 2.5 Pro)You wrote a function or shipped a feature and need full test coverage before merging. You have the code in front of you but writing tests feels slow — you keep forgetting edge cases and your PR review always comes back with 'what about null input?' or 'does this handle timeout?'Developer Tools

تولید یک test suite کامل از هر تابع یا توضیح ویژگی

اشتراک‌گذاری:
تولید یک test suite کامل از هر تابع یا توضیح ویژگی

Why this prompt matters

<p>Incomplete tests are the leading cause of regressions in production. A typical developer writing tests from memory covers 60-70% of edge cases — the remaining 30% is where bugs live. Every missed edge case is a future incident, a 2am page, or a data corruption bug discovered by a customer. Beyond bugs: code without proper tests blocks confident refactoring. You end up with unmaintainable spaghetti because nobody dares touch it. This prompt forces systematic coverage across happy paths, boundaries, failures, and integration points — the same coverage a dedicated QA engineer would produce in several hours, generated in under a minute.</p>

What we use it for

You wrote a function or shipped a feature and need full test coverage before merging. You have the code in front of you but writing tests feels slow — you keep forgetting edge cases and your PR review always comes back with 'what about null input?' or 'does this handle timeout?'

Prompt

Act as a senior software engineer and QA architect with deep expertise in test-driven development.

Context:
I have a [FUNCTION / FEATURE / MODULE] that I need fully tested. It is written in [PROGRAMMING LANGUAGE] and uses [FRAMEWORK / LIBRARY if any]. Here is the code or description:

[PASTE YOUR FUNCTION OR FEATURE DESCRIPTION HERE]

Task:
Generate a comprehensive test suite for the above. Cover ALL of the following:
1. Happy-path unit tests
2. Edge case unit tests
3. Error/failure scenarios
4. Integration test outlines
5. Security-relevant tests if applicable

Constraints:
- Write tests in [TEST FRAMEWORK, e.g. Jest, pytest, JUnit]
- Name tests: should_[expected behavior]_when_[condition]
- Do NOT write implementation code
- Group tests into describe blocks by category
- Flag any testability issues in the original code

Output Format:
- Full runnable test file with all imports
- Section comments: // === HAPPY PATH ===, // === EDGE CASES ===, etc.
- Summary table: test count per category + estimated code coverage %
- Testability issue flags

مشکل نوشتن دستی تست‌ها

از هر توسعه‌دهنده‌ای بپرسید که وقتی تحت فشار ددلاین است چه چیزی را نادیده می‌گیرد، جواب تقریبا همیشه تست‌هاست. نوشتن تست‌های جامع خسته‌کننده و از نظر ذهنی سنگین است. بیشتر توسعه‌دهنده‌ها 30 تا 40 درصد edge cases مهم را از دست می‌دهند.

این Prompt با قرار دادن تفکر سیستماتیک یک مهندس ارشد QA در یک قالب قابل استفاده مجدد، این مشکل را حل می‌کند.

چرا این Prompt موثر است

این Prompt از یک چارچوب پوشش پنج دسته‌ای استفاده می‌کند: happy path، edge cases، خطاها، integration و امنیت. محدودیت نام‌گذاری تست‌ها با الگوی should_[behavior]_when_[condition] AI را مجبور می‌کند دقیق باشد. نیاز به علامت‌گذاری مشکلات testability، مشکلات معماری را قبل از تبدیل شدن به technical debt شناسایی می‌کند.

چطور از آن استفاده کنید

Prompt را در Claude Sonnet 4.5 (یا GPT-4o) کپی کنید. سه فیلد داخل براکت را پر کنید: زبان برنامه‌نویسی، test framework و توضیحات تابع یا ویژگی. خروجی یک فایل تست آماده اجرا به همراه یک جدول خلاصه coverage است.

سازگاری با زبان‌ها و frameworkهای مختلف

برای Python از pytest، برای TypeScript از Jest یا Vitest، برای Java از JUnit 5، و برای Go از Go testing package استفاده کنید.

testingdeveloper toolsunit-testsclaudecoding
اشتراک‌گذاری: