Book Image

Test-Driven Python Development

By : Siddharta Govindaraj
Book Image

Test-Driven Python Development

By: Siddharta Govindaraj

Overview of this book

This book starts with a look at the test-driven development process, and how it is different from the traditional way of writing code. All the concepts are presented in the context of a real application that is developed in a step-by-step manner over the course of the book. While exploring the common types of smelly code, we will go back into our example project and clean up the smells that we find. Additionally, we will use mocking to implement the parts of our example project that depend on other systems. Towards the end of the book, we'll take a look at the most common patterns and anti-patterns associated with test-driven development, including integration of test results into the development process.
Table of Contents (20 chapters)
Test-Driven Python Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

What is legacy code?


In this chapter, we will use the term legacy code to mean any code that does not have unit tests. This is a rather broad definition, since it includes the code that was written long ago as well as recent code, which, for some reason, was written without tests. Although not strictly about the old code, this is a popular definition in the TDD community, made mainstream by Michael Feathers' excellent book Working Effectively with Legacy Code (Prentice Hall, 2004), and this is the meaning we will adopt in this book as well.

There are five steps to working with the legacy code:

  1. Understanding the code: If we are lucky, we will have some great documentation that will help us understand the code that we are going to touch. More likely, documentation will be scant or not present altogether. Since there are no tests, we cannot read the tests to try to understand what the code is supposed to do. And for really old code, chances are that the person who wrote the code does not work...