Test-driven development is a testing technique that consists of the three actions “writing a failing test”, “making the test pass with the minimum amount of code possible”, and “clean up the code” that are repeated in a perpetuous cycle.
For their work, Davide Fucci, Hakan Erdogmus, Burak Turhan, Markku Oivo, and Natalia Juristo assume that in reality, developers are likely to diverge from this ideal process and that they probably do not spend equal time in each phase. To investigate on this phenomenon and how it affects the number of mistakes developer make (quality) and the time they need to solve the tasks (perfromance), they conducted an experiment in which they tracked developers interactions with Eclipse to capture when developers are in which phase and for how long. A total of 39 professional developers from 2 companies participated in this study. Each participant solved 3 tasks (2 green-field tasks and one green-field tasks), which led to 82 tracked task-solving action sequences.
Based on the experiment data, they analyzed whether there is a correlation between the adherence to the TDD cycle and both quality and performances. They find that smaller granularity of the activity phases, uniformity of time spend on each action, and less time spend on refactoring correlates to higher quality, as well as better perfromance. Furthermore, it did not matter whether developers wrote the tests or the respective implementation first (i.e., the order of performing these actions did not matter). They conclude that this is most likely because developers work in baby steps in either case, which is what causes the positive effects. The idea of test-first programming is essentially a way to force developers to work in small steps.
- Read the journal paper