#46 – Test-Driven Development

Authors’ Comments:

Test-Driven Development has probably become popular because it is an approach to achieving both a high quality of code and a high code coverage. By first writing only the minimally needed part of a unit test to make it fail, and then only writing enough code to make the unit test pass, TDD supports developers in taking a simplistic approach to writing code that implements the desired behavior.

TDD is typically approached through the three stages Red (write test), Green (pass test) and Refactor (optimize). Of course, the latter stage is at least of the same importance as the former two, as not refactoring the code can potentially lead to technical debt. 

One simple way of including the Refactor step is to explicitly state in the Definition of Done that, when applicable, refactoring must have been done before a PBI can be considered done. Though this doesn’t necessarily lead to refactoring happening every time, the assessment of if its applicability is typically of benefit.