Dissertation, January 1, 2006. 354 Pages.
NOTE: At the time of publication, the author David Janzen was not yet affiliated with Cal Poly.
Test-driven development (TDD) has gained recent attention with the popularity of the Extreme Programming agile software development methodology. Advocates of TDD rely primarily on anecdotal evidence with relatively little empirical evidence of the benefits of the practice. This research is the first comprehensive evaluation of how TDD affects software architecture and internal design quality. Formal controlled experiments were conducted in undergraduate and graduate academic courses, in a professional training course, and with in-house professional development projects in a Fortune 500 company. The experiments involved over 230 student and professional programmers working on almost five hundred software projects ranging in size from one hundred to over 30,000 lines of code. The research also included a case study of fifteen software projects developed over five years in a Fortune 500 corporation. This research demonstrates that software developers applying a test-first (TDD) approach are likely to improve some software quality aspects at minimal cost over a comparable test-last approach. In particular this research has shown statistically significant differences in the areas of code complexity, size, and testing. These internal quality differences can substantially improve external software quality (defects), software maintainability, software understandability, and software reusability. Further this research has shown that mature programmers who have used both the test-first and test-last development approaches prefer the test-first approach. In addition, this research contributes a pedagogical approach called test-driven learning (TDL) that integrates TDD instruction at all levels. TDL was partially applied at all academic levels from early programming instruction through professional continuing education. Results indicate some differences between beginning and mature developers including reluctance by early programmers to adopt the TDD approach. By providing the first substantial empirical evidence on TDD and internal software quality, this research establishes a benchmark and framework for future empirical studies. By focusing on both software design and software testing, this research is already raising awareness of TDD as both a design and testing approach through publications and international awards.