Test-Driven Development (TDD) ਇੱਕ ਅਭਿਆਸ ਹੈ ਜਿੱਥੇ ਤੁਸੀਂ ਕੋਡ ਤੋਂ ਪਹਿਲਾਂ ਟੈਸਟ ਲਿਖਦੇ ਹੋ — ਇੱਕ ਛੋਟੀ, ਦੁਹਰਾਈ ਜਾਣ ਵਾਲੀ ਸਾਈਕਲ ਦੀ ਪਾਲਣਾ ਕਰਦੇ ਹੋਏ: ਇੱਕ ਅਸਫਲ ਟੈਸਟ ਲਿਖੋ, ਇਸਨੂੰ ਪਾਸ ਕਰਨ ਲਈ ਕੋਡ ਲਿਖੋ, ਫਿਰ ਰੀਫੈਕਟਰ ਕਰੋ। ਇਹ ਟੈਸਟ ਦੁਆਰਾ ਡਿਜ਼ਾਈਨ ਨੂੰ ਚਲਾਉਂਦਾ ਹੈ ਅਤੇ ਯਕੀਨੀ ਬਣਾਉਂਦਾ ਹੈ ਕਿ ਕੋਡ ਪਰਖਤ ਯੋਗ ਅਤੇ ਚੰਗੀ ਤਰ੍ਹਾਂ ਪਰਖਿਆ ਗਿਆ ਹੈ।
TDD ਸਾਈਕਲ: ਰੈੱਡ, ਗ੍ਰੀਨ, ਰੀਫੈਕਟਰ
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
