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

Making tests readable


In the previous section, we looked at the rather mundane issue of file layout and naming conventions. We are now going to take a look at the ways we can improve the test cases themselves.

Our first goal is to make it easier to understand the tests themselves. There is nothing worse than locating a test case and then having a hard time figuring out what the test is trying to do.

I'm sure I will not be the first to confess that there have been multiple occasions where I have returned to a test that I myself wrote a year back, and struggled to understand what I was trying to do.

This is an area that is often ignored because when we write the test, it seems perfectly obvious what the test does. We will need to put ourselves in the shoes of someone who is looking at the test for the first time or after a couple of years and trying to understand the test without having the contextual knowledge that we had while writing the test. This is a recurring problem when working on large...