Test-driven Development
Sviluppo guidato dai test
Lo sviluppo guidato dai test (TDD) ripete tre passaggi. Scrivi un piccolo test che fallisce. Scrivi il minimo codice che passa. Poi pulisci il codice senza cambiarne il funzionamento.
Un altro esempio
Uno sviluppatore inizia una nuova regola di arrotondamento del denaro con un esempio di test che fallisce. Il codice più piccolo la fa passare, poi il codice ripetuto viene ripulito mentre tutti i test rimangono verdi. I test scritti solo dopo il codice sono utili, ma quello non è il ciclo test-prima del TDD.
Parti principali
- 01esempio che fallisce
- 02codice minimo sufficiente
- 03refactoring sicuro
Usalo quando
Usa questo termine quando ogni passo progettuale successivo è guidato da un test fallito e seguito da una pulizia sicura.
Non usarlo quando
Non chiamare un progetto TDD solo perché ha molti test. Il codice deve seguire il ciclo test-first.
Nome usato nel codice
red → green → refactor Prima di spedire
Check the environment and prepared test data (fixture). Define a result you can observe, failure and edge cases, isolation, stable inputs, useful error details, and cleanup. Set a time budget, owner, and flaky-test rule.
Outcome: Complete the task with Sviluppo guidato dai test (Test-driven Development). User context: Uno sviluppatore inizia una nuova regola di arrotondamento del denaro con un esempio di test che fallisce. Il codice più piccolo la fa passare, poi il codice ripetuto viene ripulito mentre tutti i test rimangono verdi. I test scritti solo dopo il codice sono utili, ma quello non è il ciclo test-prima del TDD. Validation approach: Sviluppo guidato dai test (Test-driven Development). Why it fits: Usa questo termine quando ogni passo progettuale successivo è guidato da un test fallito e seguito da una pulizia sicura. Do not use it when: Non chiamare un progetto TDD solo perché ha molti test. Il codice deve seguire il ciclo test-first. Test requirements: Name the system and test environment. Define prepared test data, other inputs, and the result you can observe. Include failure and edge cases, allowed error, isolation, and cleanup. Test operations: Make failures easy to diagnose. Control random or changing inputs. Name an owner. Keep the test fast and simple enough for its release gate. Acceptance criteria: The test fails for the known bug and passes after the fix. It repeats in the target environment, gives useful evidence, and does not expose or change unrelated data. Evidence and limits (evidence boundary): Nessun singolo standard ufficiale controlla l'intero termine. Il suo significato può cambiare tra team, piattaforme o framework. Unknowns to confirm: Release gate, environment, prepared test data, allowed error, time budget, owner, and flaky-test rule.
Controlla questa richiesta
Review how Sviluppo guidato dai test (Test-driven Development) is used now. Definition: Lo sviluppo guidato dai test (TDD) ripete tre passaggi. Scrivi un piccolo test che fallisce. Scrivi il minimo codice che passa. Poi pulisci il codice senza cambiarne il funzionamento. Release checks: Check the environment and prepared test data (fixture). Define a result you can observe, failure and edge cases, isolation, stable inputs, useful error details, and cleanup. Set a time budget, owner, and flaky-test rule. Before changing code, list the evidence, gaps, severity, and the smallest safe fix.