Book Review: Python Testing Cookbook

I received a review copy of Python Testing Cookbook by Greg Turnquist late last week. The timing was perfect, since we have been talking a lot about increasing the amount of automation we use in our testing at work. I scanned through the book quickly to get a sense for whether I should give it to our QA team, and I liked what I found.

Quick Review

My review for the impatient reader:

Why I picked it up: The timing was perfect. We are applying more test automation techniques as part of improving our QA process at work, and I hoped to find some useful tools.

Why I finished it: It’s a fast read, especially when you skim over the code. There are a lot of good tips, and it introduces a range of tools, which is just what I needed.

I’d give it to: Our QA team. It will explain some of the tools the development team is already using and introduce others that are well suited for the needs of the QA team.

Review

I’m not normally a fan of “cookbook” style technology books. The ones I have read were disorganized grab-bags of random suggestions only useful to someone with a background in the topic they covered. This book is an exception. The author did a good job of organizing Python Testing Cookbook to avoid the grab-bag feeling. Each chapter introduces a new concept, and the sections and recipes build on each other in a steady progression. Because it introduces basic concepts such as the unittest and doctest frameworks before moving to test runners like nose and advanced tools such as mock, Pycurracy, robotframework, lettuce, and Jenkins, the book is useful for someone approaching test automation for the first time who wants to read straight through, without sacrificing the quick-reference goal of the cookbook format.

I’m not normally a fan of “cookbook” style technology books. This book is an exception.

The book stands up well as a beginner- or intermediate-level text because it takes the reader beyond a strict “how to” structure. In addition to the step-by-step instructions you expect, each recipe explains how the techniques employed work and gives advice about when and why to use them. Some of the best tips in the book are included in those sections.

I think our QA team will find the book especially helpful because it covers more than green field development work. Chapter 9 in particular talks about how to apply the techniques covered earlier with legacy systems. Those tips encourage you to start testing, even if it is a big project and you’re unlikely to reach 100% coverage in the short-term.

“Don’t get caught up in the purity of total isolation or worry about obscure test methods. First thing, start testing.”

Chapter 4 covers a few interesting techniques and tools for “Behavior Driven Development”. Lettuce piques my interest, as I hadn’t heard of it before. The ability to describe tests independently of the code that performs them will be useful for non-programmers (as long as they have some help to bind the test descriptions to those checks, of course).

I only have two negative comments to make. Most or all of the program output is presented as screen shots. While I’m sure that made their editing process easier (there’s no need to worry about whether a copy editor broke the output formatting or “corrected” the language in an error message), the white-on-black images don’t come out well in the printing. In a few cases is looks like the opacity for the terminal window was not set high enough to mask the text from other windows. It’s distracting, but the important text is clearly legible, so in the end it isn’t a big problem.

The other point is related to scope. A few of the more advanced tools (Jenkins and TeamCity), are introduced without a lot of depth. Basic use patterns are presented to get you started, and reference links are included for readers who want to find out more about the tools. I think this is a limitation of the size and format of the book, rather than an oversight, and so I can’t complain too much, but those sections do stand out as thinner than the others.

Recommendation

I recommend this book. It exceeded my expectations (both of the format, and of Packt’s reputation), and provides a clear introduction to tools and techniques for testing your application from a variety of perspectives.

Disclaimer: I received a free review copy of this book from the publisher.