Test-Driven Development (TDD) एक अभ्यास हो जहाँ तपाइँ कोड अघि परीक्षण लेख्नुहुन्छ — छोटो, दोहोरिने चक्र अनुसरण गरेर: असफल परीक्षण लेख्नुस्, यसलाई पास गर्न कोड लेख्नुस्, त्यसपछि रीफ्याक्टर गर्नुस्। यसले परीक्षणहरू मार्फत डिजाइन चलाउँछ र कोड परीक्षणयोग्य र राम्रोसँग परीक्षण गरिएको सुनिश्चित गर्छ।
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
