What this book covers
Chapter 1, Getting Started with Test-Driven Development, is the introductory chapter. It eases you into the TDD process by setting the context of why we need TDD and quickly getting started with a test.
Chapter 2, Red-Green-Refactor – The TDD Cycle, goes deeper into the TDD process, driving the implementation of our example project as we write more tests.
Chapter 3, Code Smells and Refactoring, explores common types of smelly code, and we go back to our example project and clean up the smells we find. A key benefit of TDD is that it provides a safety net so that we can go in and clean up messy code.
Chapter 4, Using Mock Objects to Test Interactions, shows the use of mocking to implement the parts of our example project that depend on other systems. How do you test code that depends on external subsystems? We answer that question here by introducing mock objects.
Chapter 5, Working with Legacy Code, is about the fact that we often need to clean up or add features to old code that doesn't have existing tests. This chapter looks at strategies for doing this by working through one of the modules in our sample application.
Chapter 6, Maintaining Your Test Suite, proves that unit tests are also code and good coding practices apply to test code as well. This means keeping them well organized and easy to maintain. This chapter covers techniques to do just that.
Chapter 7, Executable Documentation with doctest, goes through the usage of doctest by working through one of the modules of our application.
Chapter 8, Extending unittest with nose2, gives us a look at nose2, a powerful test runner and plugin suite that extends the unittest framework.
Chapter 9, Unit Testing Patterns, covers some other patterns for unit testing. We see how to speed up tests and how we can run specific subsets of tests. We also take a look at data-driven tests and mocking patterns.
Chapter 10, Tools to Improve Test-Driven Development, explains some popular third-party tools to help us improve our TDD practice. Some of these tools, such as py.test and trial, are test runners with some unique features.
Appendix A, Answers to Exercises, contains the answers to the exercises presented throughout this book. There are many possible solutions, each with their own advantages and disadvantages.
Appendix B, Working with Older Python Versions, describes the changes needed in order to apply the techniques in this book for older versions of Python because this book has been written for Python 3.4.