Author: Alexander Tarlinder
Publisher: Addison Wesley
Audience: Software Developers
Reviewer: Kay Ewbank
This book aims to show you how to combine development and testing by writing testable code.
The subtitle of the book is "Building Quality Into Software", and Tarlinder's point is that it's all too easy for developers to concentrate on getting the code working for 'normal' use, and to not pay enough attention to making sure the code works no matter what is thrown at it in production use. While the subject matter sounds as though it could be quite dry, Tarlinder uses good examples and makes his topics sound relevant and interesting.
The book starts with a chapter defining developer testing, and follows on with one on testing objectives, styles and roles. This describes the different approaches to testing from traditional to agile and behavior-driven.
A chapter on the testing vocabulary is described as essentially one big glossary, with explanations of the matrix of test levels and types, and the agile testing quadrant.
The main theme of the book is that developers need to think about building testing into the development cycle, and the next chapter discusses testability from a developer's perspective. Next the author looks at the concept of programming by contract, where the responsibilities between calling code and called code are formalized. Unit testing and specification-based testing techniques each get a chapter, followed by a discussion of the different types of dependencies and how to deal with them.
For those projects where many similar-looking tests are needed, Tarliner advises using parameterized data-driven tests and combinatorial tests. There's an interesting chapter on 'almost unit tests', by which Tarlinder means tests such as setting up a lightweight server such as a mail server or in-memory database for testing.
Test doubles - objects that replace a collaborator such as stubs, mocks, fakes and dummies - are covered next, followed by the more formal use of mocking frameworks such as Moq, Mockito and Spock. Two chapters on test-driven development, classic and mockist style, take a longer look at details such as the order in which to write tests, and strategies for making them pass.
The book ends with a set of chapters on working with test code, going beyond unit testing, and the use of test heuristics.
I found this book to be useful, practical, more generally relevant than I'd expected, and a lot more readable. A good read.
To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.