Test-Driven Development (TDD) ایک طریقہ کار ہے جہاں آپ کوڈ لکھنے سے پہلے ٹیسٹ لکھتے ہیں — ایک مختصر، بار بار دہرایا جانے والا سائیکل اپناتے ہوئے: ایک ناکام ٹیسٹ لکھیں، اسے پاس کرنے کے لیے کوڈ لکھیں، پھر refactor کریں۔ یہ ٹیسٹس کے ذریعے ڈیزائن کو چلاتا ہے اور کوڈ کو testable اور اچھی طرح سے tested ہونا یقینی بناتا ہے۔
TDD سائیکل: Red, Green, Refactor
1. RED → write a FAILING test for the behavior you want (it fails — the code doesn't exist yet)
2. GREEN → write the MINIMUM code to make the test PASS (just enough, don't over-build)
3. REFACTOR → improve/clean up the code (and tests) while keeping tests GREEN
→ Repeat this short cycle for each small piece of behavior.
Write test (RED) → write code (GREEN) → clean up (REFACTOR) → repeat
