Test-Driven Development (TDD) is a relatively new technique that, despite gathering a lot of momentum, has made very few inroads in our industry. However, this is a technique that is too useful to overlook any longer. In an industry where we're constantly pushing the boundaries and exploring the unknown, the benefits of TDD are a very good match for many of our development problems.
Developing software with TDD might seem backwards at first glance: First a short unit test is written, then the code to make that unit test pass is implemented, and finally the code can be refactored (without changing its functionality). At that point, the cycle is repeated over and over, always starting with a unit test. The cycle itself should be short, in the order of a couple of minutes and all of the tests are required to run before moving forward.
TDD has some very interesting consequences: It creates a safety net of unit tests, which allows for major refactorings or introducing new features late in development without fear of breaking existing code, it forces the developer to use his own code first, so it is always written from the point of view of the user of the code, it encourages more modular, simpler code that can be easily modified and reused, and it serves as a form of documentation that, unlike comments or documents, can never get out of date. Last but not least, it provides the developer with instant feedback, building his confidence in the code and even making the programming experience much more enjoyable.
The talk starts with a general overview of TDD, followed by a detailed explanation of how to put it into practice, and a live TDD demonstration implementing a high-level game task fully in TDD. The second half of the session is dedicated to some of the unique aspects of game development, such as having different hardware platforms, dealing with graphics, or using middleware and how they affect TDD. Finally, the session concludes with the lessons learned at High Moon Studios from using TDD in a variety of projects.